Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unordered List (<ul>) default indent

Tags:

html

css

Can anyone tell me why an unordered list has a default indent/padding applied to it? Can this be solved with a CSS Browser Reset?

like image 464
benhowdle89 Avatar asked Jan 24 '11 10:01

benhowdle89


People also ask

What is the default for unordered lists?

By default, unordered lists are displayed by browsers with a bullet in front of each list item . Although lists typically show up with either numbers or bullets, they don't always.

How do you indent an unordered 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.

What is the default unordered list in HTML?

To create unordered list in HTML, use the <ul> tag. The unordered list starts with the <ul> tag. The list item starts with the <li> tag and will be marked as disc, square, circle, etc. The default is bullets, which is small black circles.


2 Answers

As to why, no idea.

A reset will most certainly fix this:

ul { margin: 0; padding: 0; } 
like image 151
mingos Avatar answered Oct 26 '22 05:10

mingos


I found the following removed the indent and the margin from both the left AND right sides, but allowed the bullets to remain left-justified below the text above it. Add this to your css file:

ul.noindent {     margin-left: 5px;     margin-right: 0px;     padding-left: 10px;     padding-right: 0px; } 

To use it in your html file add class="noindent" to the UL tag. I've tested w/FF 14 and IE 9.

I have no idea why browsers default to the indents, but I haven't really had a reason for changing them that often.

like image 35
Ed Birm Avatar answered Oct 26 '22 05:10

Ed Birm