Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Browser Compatible Hanging Indent for Lists

I have an unordered list where I'm trying to control the hanging indent. On items that overflow onto two lines, I want the second line of text to line up directly under the previous line of text (not underneath the bullet point). I've got this to work in Chrome exactly the way I want it. However it's a little off in Firefox and Internet Explorer.

Here's what I currently have:

<ul style="list-style: disc inside none; margin-left: 0; padding-left: 1em; text-indent: -1em;"> <li>50 – 180</li> <li>950 – 2150</li> <li>Dual IF: 70/140, L-Band & L-Band monitor (standard)</li> </ul> 

Is there any way to make this render the same in all browsers?

like image 209
Austin Avatar asked Jul 09 '13 19:07

Austin


People also ask

How do you do a hanging indent on a list?

Right click your mouse. Select Paragraph from the resulting pop up menu. Under Indentation, use the Special pull-down menu to select hanging. Use the By menu to select a number larger than the bullet default .

How do you indent a list in HTML?

Like an ordered list element, an unordered list element (<ul>) will indent its list items — or bullet points — by default. If you'd like to change the indentation distance, then you can use the margin-left or padding-left property.

Should lists be indented?

Bulleted list items can be complete sentences or phrases or sentence fragments. Use Word's bulleted list function to create the list. List items should be double-spaced and indented .


2 Answers

Remove text-indent, change list-style to outside, and apply a padding-left to your li elements:

ul {     list-style: disc outside none;      margin-left: 0;      padding-left: 1em; } li {     padding-left: 1em; } 
like image 185
Natalie Banegas Avatar answered Oct 05 '22 17:10

Natalie Banegas


The only thing I had to add to the accepted answer was text-indent since I was using fontello bullets:

ul {     list-style: disc outside none;     margin-left: 0;      padding-left: 1em;     text-indent: -2em; }  li{     padding-left: 1em; } 
like image 44
Elliott de Launay Avatar answered Oct 05 '22 18:10

Elliott de Launay