How to Delete Browser Default Settings in CSS

Every browser has its own default settings for font size, margins and/or padding around certain elements, etc. Webdesigners should aim to have their sites display well on all kinds of browsers, but these different default settings can easily lead to problems. Sometimes, the differences are subtle and have no effect on the design, but they can also cause a page to totally break in one browser vs. another.

To demonstrate, you could look at THIS PAGE via Browsershots.org. (Just copy and paste ‘this page’ URL, then go to Browsershots and play around).

There is a quick and easy fix so. Start your stylesheet out with this:

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

The ‘*’ stands for any and all properties on your page, and this code sets them all to ZERO. Of course, now you’ll have to add your margins, padding, and any borders back in with your CSS in the right places, but usually, you’d have to do that anyway – and this way, it’s much easier to create a cross-browser compatible site.

Tags: ,

This post was written by: Andrea Barnett

This entry was posted on Tuesday, March 2nd, 2010 at 11:47 am and is filed under CSS Basics, CSS Misc, CSS Page Layouts, Killer CSS Tips and Tricks. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 Responses to “How to Delete Browser Default Settings in CSS”

  1. admin says:

    Another great post Andrea.

    Stef

  2. Seeni says:

    Great Post.

  3. Seeni says:

    Great

  4. Michael Hall says:

    excellent tip.

    I’ve finally decided to jump on the CSS bandwagon, and boy oh boy, cross-browser compatibility really makes something so easy to learn into a nightmare

  5. jay says:

    Great tip, we can also call this as “CSS Reset” :)

  6. Ahsan says:

    Believe me Andrea, I have learnt all the CSS from you, I have designed so many websites but Allot of concepts were unclear in my mind, but after reviewing your tutorials believe me i have Everything fresh in my Mind now. May God Bless you :) Keep Posting and teaching.

    Warm Regards

    Ahsan.

Leave a Reply