Languages
[Edit]
EN

CSS - remove UL list left margin

4 points
Created by:
Kate_C
2895

In this short article we would like to show how with CSS remove left margin for UL element (unordered list).

Quick solution:

/* use following style */

ul {
    padding: 0;
}

 Practicel example

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    ul {
      	border: 1px solid gray;
        padding: 0;  /* <----------------------- required */
    }
    
    li {
      	list-style-position: inside;  /* <------ optional */
    }

  </style>
</head>
<body>
  <ul>
    <li>a</li>
    <li>b</li>
    <li>c</li>
  </ul>
</body>
</html>

 

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.