Is resetting page margins/padding a good idea

aka Rohan's picture

He has: 200 posts

Joined: Feb 2006

The first thing I do when writing css for a website is add the following code to reset all margins and padding for cross browser compatibility

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

Is this always a good idea to do or is it sometimes better to keep browsers operating with their defaults. If so, why would this be beneficial?

They have: 26 posts

Joined: Mar 2007

This helps some of my sites a lot, especially if I am using a 100% width table and want to have the table right up against the left hand side of the page.

Not sure if it is always neccessary...Just depends on how you want your website to look.

Personally I like using these attributes.

Free HTML, Dreamweaver, & FrontPage Video Tutorials
http://www.Resource-Website.com
FREE WEBSITE TRAFFIC from YouTube
http://www.TubeTraffic.com

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

But then you have to go and reset all the margins and padding on everything! So there's a trade-off. Sometimes the defaults can be really annoying (such as in the case of lists), sometimes they're good enough spacing for basic elements (such as paragraphs and headings). I usually just make some adjustments to the defaults for commone elements. Thats' worked well so far for me but it does get a bit messy sometime. I don't consider myself to be a total control freak though!

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Megan;217457 wrote: But then you have to go and reset all the margins and padding on everything! So there's a trade-off. Sometimes the defaults can be really annoying (such as in the case of lists), sometimes they're good enough spacing for basic elements (such as paragraphs and headings). I usually just make some adjustments to the defaults for commone elements. Thats' worked well so far for me but it does get a bit messy sometime. I don't consider myself to be a total control freak though!

Yes, it might be annoying at first, but you can write up a basic CSS sheet that overrides all defaults and use it for everything. Do it once and be cross-browser compatible (or at least one step closer) forever.

demonhale's picture

He has: 3,278 posts

Joined: May 2005

I usually apply reset margins and paddings on nested elements...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.