A Comprehensive Guide to CSS Resets

This guide examines the infinite-like variety of CSS resets created by web developers and designers across the world.

While almost all of these CSS resets are generally provided free for public use (many through Creative Commons licensing), it is incumbent upon you to check the terms of use before putting them to use in your projects.

This guide follows Part 1, where the history of CSS resets was discussed; you’re advised to read that before this one to get the most out of this guide.

This is Part 2 of a three-part series of articles on the topic of CSS resets.

Poor Man’s Reset

The "poor man’s reset" sets the margin, padding, font-size, and borders of the html and body elements instead of all elements. This not only removes the reliance on the universal selector, but is also more conservative with what elements and CSS properties are reset.

Siolon Reset

In 2008, Chris Poteet developed a hybrid reset, incorporating the universal selector reset for a number of CSS properties, along with some selected (and idiosyncratic) reset values for individual elements such as table and li:

Tripoli Reset

One of the most far-reaching resets outside of Eric Meyer’s Reset CSS is the Tripoli Reset by David Hellsing. It is intended to work along with a foundational stylesheet to rebuild the CSS after the reset tears it down.

Hellsing’s reset addresses many deprecated HTML elements — often by disabling them — such as the <blink> and <marquee> elements, which could be handy for projects that are used by several people with varying levels of HTML knowledge. Some developers love the Tripoli Reset, others consider it major overkill.

Dan Schulz’s Reset

In August 2008, Dan Schulz, a vastly talented web designer who has since passed away, posted his idiosyncratic version of a "global" reset (which he extensively documented in the SitePoint thread he posted it in):

Schulz explained that he didn’t want to use the universal selector, but he did want to zero out the margins and padding on most elements. Since he always coded under Strict doctype, he didn’t bother resetting deprecated HTML elements. Schulz set basic font families, and went into some detail about font sizing. He used some of Meyer’s work on Reset CSS, adding a few "bug-squashing" inclusions.

Thierry Koblentz’s base.css

In March 2010, developer/designer Thierry Koblentz decided to turn the idea of a "global reset" on its head and created a base stylesheet that reset many browser defaults, not necessarily to zero, but to a value he wanted to begin his designs with.

Koblentz’s base.css is big, but much of it has to do with extensive comment documentation:

/*
* base.css | v0.4 (06132010) | Thierry Koblentz
*
* The purpose of this styles sheet is to set default styles for common browsers and address common issues (missing scrollbar, extended buttons in IE, gap below images, etc.)
*
* See: http://thinkvitamin.com/design/setting-rather-than-resetting-default-styling/
*
* Changes in this version:
* - input, button, textarea, select, optgroup, option {line-height: 1.4 !important;} (to override FF's default styling)
* - styling <ol> inside <ul> (merci Goulven)
*/
/* using height:100% on html and body allows to style containers with a 100% height
* the overflow declaration is to make sure there is a gutter for the scollbar in all browsers regardless of content
* note that there is no font-size declaration set in this rule. If you wish to include one, you should use font-size: 100.01% to prevent bugs in IE and Opera
*/
html {
height: 100%;
overflow-y: scroll;
}
/* not all browsers set white as the default background color
* color is set to create not too much contrast with the background color
* line-height is to ensure that text is legible enough (that there is enough space between the upper and lower line)
*/
body {
height: 100%;
background: #fff;
color: #444;
line-height: 1.4;
}
/* this choice of font-family is supposed to render text the same across platforms
* letter-spacing makes the font a bit more legible
*/
body, input, button, textarea, select {
font-family: "Palatino Linotype", Freeserif, serif;
letter-spacing: .05em;
}
h1, h2, h3, h4, h5, h6 {
font-family: Georgia, "DejaVu Serif", serif;
letter-spacing: .1em;
}
pre, tt, code, kbd, samp, var {
font-family: "Courier New", Courier, monospace;
}
/* These should be self explanatory
*/
h1 {font-size: 1.5em;}
h2 {font-size: 1.4em;}
h3 {font-size: 1.3em;}
h4 {font-size: 1.2em;}
h5 {font-size: 1.1em;}
h6 {font-size: 1em;}
h1, h2, h3, h4, h5 {font-weight: normal;}
/* styling for links and visited links as well as for links in a hovered, focus and active state
* make sure to keep these rules in that order, with :active being last
* text-decoration: none is to make the links more legible while they are in a hovered, focus or active state
* a:focus and :focus are used to help keyboard users, you may change their styling, but make sure to give users a visual clue of the element's state.
* outline:none used with the pseudo-class :hover is to avoid outline when a user clicks on links
* note that these last rules do not do anything in IE as this browser does not support "outline"
*/
a:link {color: #000;}
a:visited {text-decoration: none;}
a:hover {text-decoration: none;}
a:focus {text-decoration: none;}
a:focus,:focus {outline: 1px dotted #000;}
a:hover,a:active {outline: none;}
/*
* This one is commented out as it may be overkill (users who use both a mouse and the keyboard would lose keyboard focus)
* Besides, this may create a performance issue
* html:hover a {outline: none;}
*/
/* margin and padding values are reset for all these elements
* you could remove from there elements you do not used in your documents, but I don't think it'd worth it
*/
body, p, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, blockquote, th, td {
margin: 0;
padding: 0;
}
/* this is to prevent border from showing around fieldsets and images (i.e., images inside anchors)
*/
fieldset, img {
border: 0;
}
/* to prevent a gap from showing below images in some browsers
*/
img {vertical-align: bottom;}
/* Styling of list items
* This styles sheet contains a class to apply on lists to reset list-type and margin on LIs
*/
ol li,
ul ol li {list-style-type: decimal;}
ul li {list-style-type: disc;}
ul ul li {list-style-type: circle;}
ul ul ul li {list-style-type: square;}
ol ol li {list-style-type: lower-alpha;}
ol ol ol li {list-style-type: lower-roman;}
/* These should be self explanatory
* I believe *most* UAs style sub and sup like this by default so I am not sure there is value to include these rules here
*/
sub {
vertical-align: sub;
font-size: smaller;
}
sup {
vertical-align: super;
font-size: smaller;
}
/* color is to make that element stands out (see color set via body)
* padding is used so Internet Explorer does not cut-off descenders in letters like p, g, etc.)
*/
legend {
color: #000;
padding-bottom: .5em;
}
/* according to Eric Meyer's reset: tables still need 'cellspacing="0"' in the markup
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
/* caption and summary are very important for tabular data but because caption is nearly impossible to style across browsers many authors do not use it or use display:none to "hide" it (which is almost the same as not using it).
* so to prevent such workaround, I am positioning this element off-screen
*/
caption {
position: absolute;
left: -999em;
}
/* all th should be centered unless they are in tbody (table body)
*/
th {text-align: center;}
tbody th {text-align: left;}
/* See Eric Meyer's article about Fixed Monospace Sizing
* http://meyerweb.com/eric/thoughts/2010/02/12/fixed-monospace-sizing/
*/
code {color: #06f;}
code, pre {font-family: "Courier New", monospace, serif; font-size: 1em;}
/* This should be self explanatory
*/
blockquote, q, em, cite, dfn, i, cite, var, address {
font-style: italic;
}
/* to prevent some browsers from inserting quotes on "q" and "p" ("p" in blockquotes)
*/
blockquote p:before, blockquote p:after, q:before, q:after {content: '';}
/* These should be self explanatory
*/
th, strong, dt, b {
font-weight: bold;
}
ins {
text-decoration: none;
border-bottom: 3px double #333;
}
del {text-decoration: line-through;}
abbr,
acronym {
border-bottom: 1px dotted #333;
font-variant: normal;
}
/* Creating white space (vertical gutters) via padding
* most authors do not set right/left padding or margin on these elements, they rather use an extra wrapper or style the container with padding to create the left and right gap/gutter they need
* I find that the latter creates less robust layouts because it leads authors to mix padding with width which creates issue with the broken box model (IE5 or IE6 in quirks mode)
* so imho, setting this style using the child combinator (i.e., div > h1) should be the best way to do it, but unfortunately IE 6 does not support such syntax, so I have to go with the following + a reset (see next rule)
*/
h1, h2, h3, h4, h5, h6, p, pre, ul, ol, dl, fieldset, address {padding:0 30px;}
/* this is to reset the left/right gaps (created by the previous and next rules) on nested elements
*/
dd p, dd pre, dd ul, dd ol, dd dl, li p, li pre, li ul, li ol, li dl, fieldset p, fieldset ul, fieldset ol {
padding-right: 0;
padding-left: 0;
}
/* These should be self explanatory
*/
dd {
padding-left: 20px;
margin-top: .5em;
}
li {margin-left:30px;}
/* we cannot use padding on a table to create left and right gaps (as we do with the elements above), instead we use margin
*/
table {
margin-right: 30px;
margin-left: 30px;
}
/* we use margin for hr for the same reason we do for table
*/
hr {
margin-right: 30px;
margin-left: 30px;
border-style: inset;
border-width: 1px;
}
/* top margin solution */
/* this is my approach to create white space between elements, you do not have to adhere to it
* rather than stylling these elements with top and bottom margin, or simply bottom margin I only use top margin
*/
h1, h2, h3, h4, h5, h6, p, pre, dt, li, hr, legend, input, button, textarea, select, address, table {margin-top: 1.2em;}
/* top padding solution */
/* this is a different approach which may be less frustrating for novice because it avoids running into collapsing margin and allows to clear floats while preserving space above the element
* if you decide to give this a try, then comment out the above rule and uncomment the two next ones
*/
/*
h1, h2, h3, h4, h5, h6, p, pre, dt, dd, li, legend, address {padding-top: 1.2em;}
hr, input, button, textarea, select, table {margin-top: 1.2em;}
*//* form elements
* this should not affect the layout of the labels unless you style them in a way that padding applies
* if I include this here it is mostly because when labels are styled with float and clear, top padding creates a gap between labels (bottom margin would, but not top margin)
*/
label {padding-top: 1.2em;}
/* line height helps to set the vertical alignment of radio buttons and check boxes (remember to group these in fieldsets)
*/
fieldset {line-height: 1;}
/* vertical alignment of checkboxes (a different value is served to IE 7)
*/
input[type="checkbox"] {
vertical-align: bottom;
*vertical-align: baseline;
}
/* vertical alignment of radio buttons
*/
input[type="radio"] {vertical-align: text-bottom;}
/* vertical alignment of input fields for IE 6
*/
input {_vertical-align: text-bottom;}
/* a specific font-size is set for these elements
* the line-height is to override FF's default styling
*/
input, button, textarea, select, optgroup, option {
font-size: .9em;
line-height: 1.4 !important;
}
/* this is to fix IE 6 and 7 which create extra right/left padding on buttons
* IMPORTANT: because IE 6 does not understand the first selector below, you need to apply the class "inputButton" to all input of type="button" in your documents
* the first declaration is for IE 6 and 7, the second one for IE 6 only, the third one is for all browsers.
*/
button,
input[type="submit"],
input[type="reset"],
input[type="button"],
.inputButton {
*overflow: visible;
_width: 0;
padding: .2em .4em;
}
/* classes
* to style elements with the default padding and margin we set on headings, paragraphs, lists, etc.
* for example, this class could be used on a DIV inside a blockquote or a DIV inside a FORM, etc.
*/
.block {
padding: 0 30px;
margin-top: 1.2em;
}
/* to swap padding for margin
* for example, this class could be used on a heading you'd style with a bottom border
*/
.padding2margin {
margin-right: 30px;
margin-left: 30px;
padding-right: 0;
padding-left: 0;
}
/* list items are styled by default with markers (disc, etc.) and left margin
* if you apply the class "noMarker" to a list, its items won't display markers and won't have left margin
*/
.noMarker li {
list-style: none;
margin-left: 0;
}

Koblentz’s base.css does a number of things other resets do not, including:

Forcing a gutter for a vertical scrollbar

Incorporating an IE button fix

Prevention of what he calls "mysterious gaps below images"

Stopping the descender of some letters from being cut off inside <legend> elements in IE

Vertically aligning checkboxes and radio buttons with their label

Setting a default color background for the document

Styling lists by default

Creating horizontal and vertical whitespace

Like some other resets, Koblentz warns that base.css includes IE "hacks" that prevent the stylesheet from validating.

Simple Reset

In April 2010, Russ Weakley gave us a much more targeted and limited reset, which he called Simple Reset.

In his explanation of Simple Reset, he noted that it removed margins and padding only from selected elements, as opposed to the wholesale removal made by the resets that rely on the universal selector.

Other things Simple Reset does:

Removes top margins on paragraphs and headings

Removes borders from fieldsets and images

Sets table borders and spacing

Sets values for a number of table-related elements (such as <th> and <td>)

Weakley reminded CSS reset users: "As with any of the resets, you should do what you feel comfortable doing!"

He echoed Eric Meyer in reminding users of Reset CSS that these style rules are not "self-contained black box[es] of no-touchiness," but tools to be used, tweaked, and modified for the project’s needs.

CSS Mini Reset

Designer Vladimir Carrer combined elements from Weakley’s and Meyer’s resets to create what he called the CSS Mini Reset:

It is much less overarching than either Weakley’s or Meyer’s efforts, focusing primarily on resetting margins and padding, stripping default values from table elements, resetting headings to normal font weight, and removing borders from margins.

Carrer says that CSS Mini Reset is best used "when you actually don’t want to reset everything."

Carrer based his reset on Azbuka, an earlier and much more complex effort at a typographically-based reset and base stylesheet he created in 2009.

Soft Reset

Around the same time Carrer released his reset, web designer Mark Aplet contributed his Soft Reset. Aplet explained that his reset "attempts to hone in and reset only the properties that really need to be reset, leaving some styling to the browser."

The CSS reset is based on Eric Meyer’s Reset CSS. As explained by Clark, it goes significantly farther than your average global reset stylesheet. It removes elements that have been deprecated from the HTML5 specs, adds new HTML5 elements to remove default padding, margins, and borders, and corrects the frequently repeated "unstyling" of the :focus pseudo-class.

Clark notes that some of the code included in the HTML5 reset is there more by personal preference than anything else (a caveat that is essentially true of all the resets available).

The creators of HTML5Reset says that although the reset is not "the end-all and beat-all" solution, they think that "it’s a fairly good starting place that anyone can take and make their own."

Clark explained some of his thinking behind the HTML5 reset:

When I decided to create a reset stylesheet for HTML5, it was primarily for a project I was working on and figured I might as well release it to be used, modified and improved by the community at large. The main differences from Eric’s stylesheet … are the removal of those absent elements in HTML5, including the new elements and declaring those as block level elements (something that will later be built into browser stylesheets and can be removed from the reset). Also included is some baseline styling for the mark element and a few other bits that I tend to use in every project so it makes sense for me to include them. I also decided to remove the default anchor styling from Eric’s stylesheet so that the outline wasn’t suppressed on links. It has a comment in Eric’s original but rarely seemed to get changed by authors. This highlights one of the biggest issues with CSS resets — you have to craft your own that works for you and for specific projects. It’s unlikely that a reset that works for one site will be exactly what’s required for the next. I’d always suggest using a reset as a starting point and then modifying it for your own needs.

CSS Reset – Refreshed

Web designer Jeffrey King updated Meyer’s original reset for HTML5; his revision is called CSS Reset – Refreshed:

HTML5 Boilerplate

Let’s end the guide with a wildly popular project that many of us are constantly talking about: Paul Irish’s and Divya Manian’s HTML5 Boilerplate, a fully developed "framework" — the creators say that it isn’t a framework — that includes a robust, HTML5-friendly reset.

The CSS reset in HTML5 Boilerplate is an amalgamation of HTML5Reset and Eric Meyer’s Reset Reloaded + HTML5 baseline.

Clark (one of the creators of HTML5Reset) says that HTML5 Boilerplate "really highlights how the web community is very good at sharing and opening up for public use."

Conclusion

There are many options for setting your CSS to baseline defaults, as can be seen above. What’s important to note is that you should use what works best for you and the project at hand. You can use an already-existing reset stylesheet, piece several of them together, or build your own from scratch; the choice is yours.

The third and final part of this series discusses the ongoing debate on whether or not we should reset our CSS in our site builds.

This is Part 2 of a three-part series of articles on the topic of CSS resets.