Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

proper indenting for ordered lists in html

I cannot get an ordered list to show proper indenting. The numbers are all aligned to the right. So the browser (Chrome) shows a space before the single digit numbers and only aligns the double digit numbers correctly to the left.

How can I output a nice ordered list where the numbers are all aligned to the left and the list items all start below each other?

like image 914
reggie Avatar asked Sep 21 '10 09:09

reggie


2 Answers

Actually, the solution is pretty simple, just set

ol {list-style-position: inside;}

And your numbers should "align to the left" like you want.

like image 133
Jo Sprague Avatar answered Sep 27 '22 18:09

Jo Sprague


Late to the party but I've just been wrestling with this problem myself and ended up using this combo which adds a zero before any single digit list items:

ol {
    margin:0px 0;
    padding:0;
    list-style: decimal-leading-zero inside none;
}

ol li 
{
    margin: 0px;
    padding: 0px;
    text-indent: -2.2em;
    margin-left: 3.4em;
}
like image 22
Paul Avatar answered Sep 27 '22 17:09

Paul