How to remove indentation from an unordered list item?

antonpug picture antonpug · Dec 18, 2012 · Viewed 310k times · Source

I want to remove all indentation from ul. I tried setting margin, padding, text-indent to 0, but no avail. Seems that setting text-indent to a negative number does the trick - but is that really the only way to remove the indentation?

Answer

j08691 picture j08691 · Dec 18, 2012

Set the list style and left padding to nothing.

ul {
    list-style: none;
    padding-left: 0;
}​

ul {
  list-style: none;
  padding-left: 0;
}
<ul>
  <li>a</li>
  <li>b</li>
  <li>c</li>
</ul>

To maintain the bullets you can replace the list-style: none with list-style-position: inside or the shorthand list-style: inside:

ul {
  list-style-position: inside;
  padding-left: 0;
}

ul {
  list-style-position: inside;
  padding-left: 0;
}
<ul>
  <li>a</li>
  <li>b</li>
  <li>c</li>
</ul>