CSS Reset: Ways and Advantages

CSS Reset: Ways and Advantages

In HTML/CSS by TK

6 Jan

CSS Reset or Reset CSS  are one of the best ways to ensure you have a consistent web layout and design across all browsers. In this post we discuss the different ways and the advantages or disadvantages of using them.

What is CSS Reset and Why use it?

CSS Reset has been around for quite some time now (thanks to Eric Meyer)and the means to achieve the same are numerous.

Smashing Magazine says

Global Reset is needed to ensure the more or less identical cross-browser presentation of your web-sites. By default different browsers use different values for margin, padding or line-height. Global Reset makes sure all (or probably most) browsers render sites identically.

Let me try to explain why the hell it is important. Let us assume that a browser decides to change the way the visited links are displayed in violet to black. Now imagine you had been using a non resetting CSS.  Once the page is viewed in the new browser, what used to violet links will now be black. The problem is not with the fact whether the link should be violet or black, but with the fact that it will not be what you would have wanted them to be. To add to it, the same element would be different in different browser leading to confused users.

Six Revisions gives a perfect example of what the above situation leads to with this image.

That is just the beginning of things, imagine each margin and padding being aligned differently in the sea of browsers. That sweet image you had positioned so well to merge with the text might just start looking like a lion roaming in Antarctica.

Jonathan Christopher points out some of the advantages that he feels save his day here.

The Other School of thought! (Disadvantages of using CSS Reset)

There is another school of thought among the web designers (when did we agree on one thing ever!) that refutes the use of CSS Reset as bloated and often unnecessary code. Jonathan Snook shouted it out loud in the most humble way back in 2008 by claiming that the ’slight differences’ were acceptable to him and his designs and that he has never felt the need for a reset stylesheet to save time just because each design is poles apart from the last one.

Jens Meiert says it very craftily as

A novice should not use them, an expert would not use them.

Overwriting CSS, load time and hindering usability are the other things pointed by the champions of this thought.

Clearly being a fan of CSS Reset, I will not indulge in sweet talk about how intelligent their reasons are but yes, they are people who know a lot more than me and probably have their reasons for preferring not to use CSS Resets.

So, do I use it or not?

Eric the man says it all so smoothly, that I would not dare to add a word of my thoughts to malign it.

Reset styles clearly work for a lot of people, whether as-is or in a modified form. As I say on the reset page, those styles aren’t supposed to be left alone by anyone. They’re a starting point. If a thousand people took them and created a thousand different personalized style sheets, that would be right on the money. But there’s also nothing wrong with taking them and writing your own overrides. If that works for you, then awesome.

For others, reset styles are more of an impediment. That’s only to be expected; we all work in different ways. The key here, and the reason I made the approving comment above, is that you evaluate various tools by thinking about how they relate to the ways you do what you do—and then choose what tools to use, and how, and when. That’s the mark of someone who thinks seriously about their craft and strives to do it better……

……Because this isn’t a field of straightforward answers and universal solutions. We are often faced with problems that have multiple solutions, none of them perfect. To understand what makes each solution imperfect and to know which of them is the best choice in the situation—that’s knowing your craft. That’s being a craftsman/craftswoman. It’s a never-ending process that is all the more critical precisely because it is never-ending.

So it’s no surprise that we, as a community, keep building and sharing solutions to problems we encounter. Discussions about the merits of those solutions in various situations are also no surprise. Indeed, they’re exactly the opposite: the surest and, to me, most hopeful sign that web design/development continues to mature as a profession, a discipline, and a craft. It’s evidence that we continue to challenge ourselves and each other to advance our skills, to keep learning better and better how better to do what we love so much.

I wouldn’t have it any other way.

Ways to achieve CSS Reset

Disclaimer: Many CSS codes in this articles have been meticulously formatted by Perishable Press for their article on CSS Reset. Jeff Starr from Perishable Press was kind so as to point a missing reference to his site and we are extremely sorry for the honest mistake.

The ways to achieve  CSS Reset are many and thankfully each has its own advantages and disadvantages (or rather shortcomings). However this particular entry at CSS Tricks surprised the hell out of me. Seriously 26%!!

Let us now look at the ways to achieve the CSS Reset from some of the best minds on the web (minds probably more useful than yours or mine).

Minimalist Reset

Andrew Krespanis started off the trend with this minimal global reset back in 2004. The universal selector ‘*’ acts as a wildcard and thus all elements fall under this. As a result all padding and margins are removed.

* {
  margin: 0;
  padding: 0;
}

It is imperative to note that the universal selector is not so universal.

Also the code is very heavy on the rendering agent to apply rules to every single element in the document, especially with large web pages, and this can also destroy a lot of good default styling. Unfortunately, this is one of the most widely used CSS Reset methods due to its short and crisp nature.

Other variants of this technique include the following:

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

OR

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

Eric Meyer CSS Reset

This is probably the best thought and useful CSS Reset or CSS Baseline methods that I know of (I know very little). This is heavy-duty stuff, effectively neutralizing virtually every significant aspect of default, browser-applied CSS rules. This reset ruleset is far-reaching, resetting many differentCSS properties. Keep this in mind during subsequent CSS development. If you experience unexpected, unexplainable behavior happening with your styles, begin by investigating and eliminating suspected aspects of this code.

/* 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;
}

You can find more about the code at the official Reset Page here.

The Meyer Reset has been streamlined by web designers so that it is less invasive as following:

body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6,
pre, form, fieldset, input, textarea, p, blockquote, th, td {
	padding: 0;
	margin: 0;
	}
fieldset, img {
	border: 0;
	}
table {
	border-collapse: collapse;
	border-spacing: 0;
	}
ol, ul {
	list-style: none;
	}
address, caption, cite, code, dfn, em, strong, th, var {
	font-weight: normal;
	font-style: normal;
	}
caption, th {
	text-align: left;
	}
h1, h2, h3, h4, h5, h6 {
	font-weight: normal;
	font-size: 100%;
	}
q:before, q:after {
	content: '';
	}
abbr, acronym {
	border: 0;
	}

Yahoo UI CSS Reset

YUI Reset CSS file removes and neutralizes the inconsistent default styling of HTML elements, creating a level playing field across A-grade browsers and providing a sound foundation upon which you can explicitly declare your intentions.

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
	margin:0;
	padding:0;
}
table {
	border-collapse:collapse;
	border-spacing:0;
}
fieldset,img {
	border:0;
}
address,caption,cite,code,dfn,em,strong,th,var {
	font-style:normal;
	font-weight:normal;
}
ol,ul {
	list-style:none;
}
caption,th {
	text-align:left;
}
h1,h2,h3,h4,h5,h6 {
	font-size:100%;
	font-weight:normal;
}
q:before,q:after {
	content:'';
}
abbr,acronym { border:0;
}

Tripoli CSS Reset

By resetting and rebuilding browser standards, Tripoli forms a stable, cross-browser rendering foundation for your web projects.”A set of default-CSS-files is supposed to give you a profound foundation for cross-browser compatible CSS-based designs. All default-values – including dozens of elements – tables, lists, typography, but also headers (h1 – h6), abbreviations, citations, quotes and forms are selected to enable an optimal legibility and well-structured text presentation.

/*
    Tripoli is a generic CSS standard for HTML rendering.
    Copyright (C) 2007  David Hellsing

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

* {
	text-decoration: none;
	font-size: 1em;
	outline: none;
	padding: 0;
	margin: 0;
	}
code, kbd, samp, pre, tt, var, textarea,
input, select, isindex, listing, xmp, plaintext {
	white-space: normal;
	font-size: 1em;
	font: inherit;
	}
dfn, i, cite, var, address, em {
	font-style: normal;
	}
th, b, strong, h1, h2, h3, h4, h5, h6 {
	font-weight: normal;
	}
a, img, a img, iframe, form, fieldset,
abbr, acronym, object, applet, table {
	border: none;
	}
table {
	border-collapse: collapse;
	border-spacing: 0;
	}
caption, th, td, center {
	vertical-align: top;
	text-align: left;
	}
body {
	background: white;
	line-height: 1;
	color: black;
	}
q {
	quotes: "" "";
	}
ul, ol, dir, menu {
	list-style: none;
	}
sub, sup {
	vertical-align: baseline;
	}
a {
	color: inherit;
	}
hr {
	display: none;
	}
font {
	color: inherit !important;
	font: inherit !important;
	color: inherit !important; /* editor's note: necessary? */
	}
marquee {
	overflow: inherit !important;
	-moz-binding: none;
	}
blink {
	text-decoration: none;
	}
nobr {
	white-space: normal;
	}

Tantek UndoHTML CSS

Tantek’s CSS Reset is a solid choice for removing many of the most obtrusive default browser styles. This reset removes underlines from links and borders from linked images, eliminates padding and margins for the most common block-level elements, and sets the font size to 1em for headings, code, and paragraphs. As an added bonus, Tantek’s reset also “de-italicizes” the infamous address element!

/* undohtml.css */
/* (CC) 2004 Tantek Celik. Some Rights Reserved.                  */
/* http://creativecommons.org/licenses/by/2.0                     */
/* This style sheet is licensed under a Creative Commons License. */

:link, :visited {
	text-decoration: none;
	}
ul, ol {
	list-style: none;
	}
h1, h2, h3, h4, h5, h6, pre, code, p {
	font-size: 1em;
	}
ul, ol, dl, li, dt, dd, h1, h2, h3, h4, h5, h6, pre,
form, body, html, p, blockquote, fieldset, input {
	padding: 0;
	margin: 0;
	}
a img, :link img, :visited img {
	border: none;
	}
address {
	font-style: normal;
	}

HTML5 Reset

A modification of Meyer’s Reset for HTML 5.

/*
html5doctor.com Reset Stylesheet
v1.4
2009-07-27
Author: Richard Clark - http://richclarkdesign.com
*/

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, dialog, figure, footer, header,
hgroup, menu, nav, section,
time, mark, audio, video {
    margin:0;
    padding:0;
    border:0;
    outline:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
}

body {
    line-height:1;
}

article, aside, dialog, figure, footer, header,
hgroup, nav, section {
    display:block;
}

nav ul {
    list-style:none;
}

blockquote, q {
    quotes:none;
}

blockquote:before, blockquote:after,
q:before, q:after {
    content:'';
    content:none;
}

a {
    margin:0;
    padding:0;
    border:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
}

ins {
    background-color:#ff9;
    color:#000;
    text-decoration:none;
}

mark {
    background-color:#ff9;
    color:#000;
    font-style:italic;
    font-weight:bold;
}

del {
    text-decoration: line-through;
}

abbr[title], dfn[title] {
    border-bottom:1px dotted #000;
    cursor:help;
}

table {
    border-collapse:collapse;
    border-spacing:0;
}

hr {
    display:block;
    height:1px;
    border:0;  
    border-top:1px solid #cccccc;
    margin:1em 0;
    padding:0;
}

input, select {
    vertical-align:middle;
}

Other Reset CSS approaches

While the most famous ones have been covered in the article, here are a few others that you might be interested in:

Further Resources on CSS Reset

I hope the article was worth the time that went into writing it and hopefully we can see some of your personal custom Reset methods in the comments.

Related Posts with Thumbnails

Tags:

About TK

Tuhin is a young designer from India who is coincidentally the founder of Inspiring Pixel. He is a lover of beauty be it in art, web or his cuppa of coffee. He enjoys watching ManUtd play and worships Led Zeppelin. Catch his nonsense whimsical ideologies @tuhinkumar

  • ('DiggThis’)
  • Delicious
  • StumbleUpon.com
  • submit to reddit

29 Responses to “CSS Reset: Ways and Advantages”

    • TK 06. Jan, 2010 at 5:40 PM #

      Thanks for the link Ellis. That really is one well thought off CSS Reset. Many developers I know of have implemented Meyer’s Reset with some personal magic. Also the Font sizing IE bug and Safari issues have been well dealt with in the CSS.

    • Nicole Foster 18. Jan, 2010 at 12:36 AM #

      Thanks for using my CSS reset (:

      The font sizing issue has been bugging me for a very long time with coding, so with some exploring, I found a rather nice solution. Plus, the blockquote issue has always been an occurring annoyance for me and it’s good to reset your forms so you can personally customize them.

  1. David Pratt 08. Jan, 2010 at 12:28 PM #

    Very good write up. I wasn’t aware of the HTML 5 Doctor reset stylesheet, but I think I think I’ll use that as a starting point on new site builds.

    • TK 08. Jan, 2010 at 12:32 PM #

      To be honest I learnt about it just before I wrote the article. No end to what can surprise your intelligence in todays world. Will be using it on my new sites myself. Looks clean for starters.

  2. Chris 08. Jan, 2010 at 1:46 PM #

    Great writeup and great blog! It looks like you’ve got some good stuff here. I’ll be following your work with interest.

  3. PVC stolarija Elatio 08. Jan, 2010 at 10:38 PM #

    Great tutorial, very helpfull :-)

    • TK 08. Jan, 2010 at 11:03 PM #

      Glad you liked it. Seems to have been really appreciated by a lot many people.

  4. Shawn Hooghkirk 08. Jan, 2010 at 11:56 PM #

    Great post TK. Although not always the most entertaining subject, but nonetheless a necessary one. *Bookmarked.

  5. Travis Berry 09. Jan, 2010 at 1:11 AM #

    I’ve been using the Eric Meyer CSS Reset for the last 6 months or so. Seems to work well for me.

  6. Cory 09. Jan, 2010 at 7:55 PM #

    Good collection of resets. I’ll reference this next time i start on a site and grab the most appropriate. That makes me wonder, is there a css reset generator out there?

    I’m picturing something where you select the elements you know you’ll be using for your project, and it spits out the proper reset styles for those elements.

  7. aravind 10. Jan, 2010 at 7:34 AM #

    Great job pal. This is the most elaborated post ever I have seen on CSS Resets. This post will be a good reference for css coders.
    Way to go! :)

  8. EllisGL 10. Jan, 2010 at 7:38 AM #

    One thing I would like to see in framework is a process that figures out which tags are used and output the reset css according to those. This idea is based on something I read about resets slowing browsers down due to resetting unused tags..

  9. jose 25. Jan, 2010 at 6:07 AM #

    hola

  10. whatdoesitwant 25. Jan, 2010 at 9:47 AM #

    That’s a very nice list. Thank you for showing the cons of using *. Hopefully people will become more careful to use it.
    I really dislike Tripoli by the way. It smells like a Napoli garbage belt, hiding all the deprecated tags. Maybe it’s just old.
    Also, Richard Clarke’s css is not so much a reset as it is an override. I would lift some of his declarations to a theme’s “base.css”.
    Also, when dealing with a cms that runs the risk of receiving deprecated content from import or lousy wysiwyg, instead of using reset i like to apply a warning using something like the following for the (scarily) common problems (rather put this in the base css than in the reset though):

    /* marking accidental illegal tags */
    big, font, small, b, i, u, s, strike, center, acronym
    {
    color: red;
    }

  11. Mads Nielsen 25. Jan, 2010 at 12:29 PM #

    Nice article, showing options and their respective pros and cons rather than telling people that “this (my) way is the only way” is much more educating.

    This isn’t exactly related to css resets, but I’d like to recommend everyone to take a quick look at Uni-Form if they Haven’t done so already

    About avoiding using a css reset, I have a horror-story of my own involving two incompetent designers, a 1400+ line stylesheet (with dreaded z-index all over the place) for a run-of-the-mill web solution and a lot of whining about the reset interferring with their own css.

    TLDR; If your css looks like a clusterfuck, its probably not the resets fault.

    • TK 29. Jan, 2010 at 2:23 AM #

      @Mads Haha! Looks like you had some tough time with Resets and bloated code. Never happened with me, so cannot really share my opinion but I guess you are bang on target.
      @Others Thanks a lot for dropping by and commenting your thoughts.

Trackbacks/Pingbacks

  1. links for 2010-01-09 | Starving Designer :: Be Awesome! - 09. Jan, 2010

    [...] CSS Reset: Ways and Advantages | Inspiring Pixel (tags: css webdesign tips reference) [...]

  2. User Kind Blog » Blog Archive » CSS resets - 09. Jan, 2010

    [...] over at Inspiring Pixel wrote a good post on the pros and cons to using a css reset, and also provides a bunch of different reset scripts based on your needs. I’ll definitely be [...]

  3. links for 2010-01-09 « Mandarine - 10. Jan, 2010

    [...] CSS Reset: Ways and Advantages (tags: webdev tutorial css) [...]

  4. CSS???????? : SS labs « SS labs - 25. Jan, 2010

    [...] CSS Reset: Ways and Advantages [...]

  5. links for 2010-01-24 « Stand on the shoulders of giants - 25. Jan, 2010

    [...] CSS Reset: Ways and Advantages | Inspiring Pixel (tags: css reference tutorial) [...]

  6. CSS RESET « Ronald Jusuf's Virtual Ramblings - 25. Jan, 2010

    [...] http://inspiringpixel.com/tutorials/htmlcss/css-reset-ways-and-advantages/346/ Possibly related posts: (automatically generated)CSS Reset StylesheetsCSS Reset — Cross Compliant [...]

  7. DeToatePentruToti.INFO » Blog Archive » Links for 2010-01-24 [del.icio.us] - 27. Jan, 2010

    [...] CSS Reset: Ways and Advantages | Inspiring Pixel CSS Reset or Reset CSS are one of the best ways to ensure you have a consistent web layout and design across all browsers. In this post we discuss the different ways and the advantages or disadvantages of using them. [...]

  8. [?]NHK????????????? | Kechol - 30. Jan, 2010

    [...]     21:29 ResetCSS?????????????YUI??????????????? RT @Web2Discover: CSS Reset: Ways and Advantages | Inspiring Pixel [...]

  9. Really Useful Tutorials You Should Have Read in January 2010 Ajax Help W3C Tag - 11. Feb, 2010

    [...] CSS Reset: Ways and Advantages By Tuhin Kumar, January 6th, 2010 Site: Inspiring Pixel [...]

  10. Articles of the Week 2/14 « Andy's Blog - 14. Feb, 2010

    [...] CSS Reset: Ways and Advantages ▶ No Responses /* 0) { jQuery('#comments').show('', change_location()); jQuery('#showcomments a .closed').css('display', 'none'); jQuery('#showcomments a .open').css('display', 'inline'); return true; } else { jQuery('#comments').hide(''); jQuery('#showcomments a .closed').css('display', 'inline'); jQuery('#showcomments a .open').css('display', 'none'); return false; } } jQuery('#showcomments a').click(function(){ if(jQuery('#comments').css('display') == 'none') { self.location.href = '#comments'; check_location(); } else { check_location('hide'); } }); function change_location() { self.location.href = '#comments'; } }); /* ]]> */ Click here to cancel reply. [...]

Leave a Reply

Web Analytics