Languages

How to remove left margin with CSS or HTML when I use UL element?

2 points
Asked by:
Marcin
2484

 Is there simple way how to remove left margin from unordered list?

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <ul style="border: 1px solid red">
    <li>a</li>
    <li>b</li>
    <li>c</li>
  </ul>
</body>
</html>
1 answers
2 points
Answered by:
Marcin
2484

padding: 0 for ul element should solve the problem

Check the link: https://dirask.com/posts/CSS-remove-UL-list-left-margin-1AvbzD

or below example:

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
  <style>

    ul {
      	padding: 0;  /* <----------------------- required */
    }
    
    li {
      	list-style-position: inside;  /* <------ optional */
    }

  </style>
<body>
  <ul style="border: 1px solid red">
    <li>a</li>
    <li>b</li>
    <li>c</li>
  </ul>
</body>
</html>

 

0 comments Add comment
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.