CSS Tip: Set Your Own Defaults
Monday, September 22nd, 2008I love CSS – you can make sweeping changes across your site by changing your stylesheet. One of my favorite tags is one that I use first in every stylesheet:
* {
margin: 0;
padding: 0;
}
This wipes out all of the default margins and padding your browser assigns to things like paragraphs, lists, headings and the like. The reason this is important to me is that I like for my sites to look the same, cross-browser, as much as is feasible. The defaults in different browsers are not always the same, and this rule allows ME to decide, not a browser company, how my site will look.
This tag means that you will have to assign margins and padding to each element yourself, but with CSS, that’s a job you’ll only have to do once – and if you change your mind later, you can always just change the stylesheet to change all the pages on your site!

