Main Contents

CSS Tools: Reset CSS

Code February 29, 2008

After reading the post and miscellaneous comments on CSS-Tricks on the subject of What Kind of CSS Reset Do You Use? I went and looked at Meyer’s CSS Tools: Reset CSS - several comments had mentioned it. It is a really good and THOROUGH one and in my own, day to day quick-and-dirty designs I never have a chance to run into the more elaborate difficulties which this stylesheet covers (I think some boss of mine would probably turn instantly gray if I’d suggest to let older browsers depreciate while the newer ones get fully fletched latest CSS beauty).

Now, after studying the following Reset CSS, I have to admit that I might actually be changing my old habits - have it as a default file and link it to each new HTML design you make as first in the line (before the current site design) and you really have a solid ground to build on:

Meyer’s CSS Tools: Reset CSS

The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on. The general reasoning behind this was discussed in a May 2007 post, if you’re interested. Reset styles quite often appear in CSS frameworks, and the original “meyerweb reset” found its way into Blueprint, among others.

The reset styles given here are intentionally very generic. There isn’t any default color or background set for the body element, for example. I don’t particularly recommend that you just use this in its unaltered state in your own projects. It should be tweaked, edited, extended, and otherwise tuned to match your specific reset baseline. Fill in your preferred colors for the page, links, and so on.

In other words, this is a starting point, not a self-contained black box of no-touchiness.

If you want to use my reset styles, then feel free! It’s all explicitly in the public domain (I have to formally say that or else people ask me about licensing). You can grab a copy of the file to use and tweak as fits you best. If you’re more of the copy-and-paste type, or just want an in-page preview of what you’ll be getting, here it is.

/* v1.0 | 20080212 */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}

/* remember to define focus styles! */
:focus {
outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}

/*
Acknowledgments
Thanks to Paul Chaplin for the blockquote / q rules.*/

 

5 Comments

  1. Chris Coyier February 29, 2008 @ 11:38 am

    Hey thanks for the link =)

    The Meyer reset certainly has it’s charms. It’s certainly through and has a bunch of nice reminders like the bit about focus styles. I find it’s typically overkill on much of what I design but I think it’s amazing if you are starting with a framework like Blueprint already.

    I also like how it gracefully steps around messing with default styling for inputs and textareas and stuff which can cause problems.

    One thing I would add to the ul/ol section is “inside”. Setting the style to none takes away the default bullets (great), but if you go ahead and put back in a style type of some kind they will still default to be outside of the box, which makes zero sense to me. Setting that list-style to none inside would be smart I think.

  2. marlyse February 29, 2008 @ 6:31 pm

    Thanks Chris for your input! Yes, I agree, “inside” is definitely the much better default.

  3. Jeff Starr March 2, 2008 @ 10:01 am

    I also think that the Meyer reset is a great tool for CSS neutralization, however, there are plenty of other useful CSS resets also available. I recently created a reference covering many excellent CSS Global Reset Styles. Lots of great choices to choose from (including the Meyer reset).

  4. marlyse March 2, 2008 @ 1:03 pm

    Thanks for your input Jeff and the link to your collection, I really appreciate the work you put in to list all the different ones including the information to it. The minimalistic approach #2 which you list on your site is the one which I do for my “quick-and-dirty” websites and it sets a nice foundation with that. For a time being (while working under Vista) I used the table {border-collapse: collapse;} on the global level too, but ran into problems then under IE7/XP with it, so now I use this only for specific tables and that works then also fine under IE7/XP.

  5. mStudiosTALK | Simplicity and your style sheets. March 13, 2008 @ 7:03 am

    [...] the past few days I have talked about CSS Reset, from simplest to intricate, and also talked about a simple way to indicate (highlight) the current page in the navigation bar [...]

Leave a comment