Taming Margins & Padding

Even if browsers are thrown into XHTML Strict mode, there are still implementation differences amongst them. Usually to do with slightly different margins and padding on certain elements, such as <ul>. Additionally, I’m not necessarily fond of the default margins and padding of some of the elements, so I tend to re-set them anyway.

One trick I’ve found is to simply set all the margins and padding, for every element, to zero right at the beginning. Then, as I use different elements, I can set them to the appropriate values for the site design.

The code is trivial. At the top of the main CSS file, put in the following line:

1
* { margin: 0; padding: 0; }



Leave a Reply