Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML / CSS : Reset List Padding to Default

I'm using *{margin:0; padding:0;} and this is the first time that it breaks me in something. List paddings and margins are 0 too, so the indentation is lost. and I would like to reset them to their original state, how is this possible?

I've tried this with no success:

ul,ol{ 
   margin :auto; /* This Works */
   padding:auto; /* This Not :( */
}

So how should I fix this?

like image 432
Adam Halasz Avatar asked Apr 06 '11 03:04

Adam Halasz


People also ask

How do I get rid of default padding and margin in CSS?

Adjusting the Margin Size of an HTML Element With CSS You can remove this margin by setting the top and left margin to zero. Like the padding and border, the sizes of specific sides of the margin can be set using margin-left , margin-right , margin-top , and margin-bottom .

What is the default margin and padding?

Default margins, borders and padding are all 0, so when you wrap a div around some text, there is no space between its edges and the text. div elements obey the box model strictly, while adding padding etc. to table cells can be interpreted a bit more loosely by browsers.


2 Answers

The point of a reset is to eliminate variations due to browser defaults. In other words, there is no definitive way to "unreset" because different browsers may have different defaults.

However, you can choose your own default values, and I think that's what you're trying to do here.

A good way to do this is to look at a browser's default stylesheet (you should be able to find how to do this by doing a search). For example, you can see the Firefox default stylesheet with this URL: resource://gre/res/html.css

like image 154
jdigital Avatar answered Oct 19 '22 02:10

jdigital


There is no way to restore default values, but changing padding of 'ol' or 'ul' and 'li' it will look fine. This works for me..

ol{
    padding: 0 25px;
}
ol li{
    padding-left: 0px;
}
like image 24
Juan Avatar answered Oct 19 '22 01:10

Juan