share
Stack OverflowBest css reset
[+287] [20] Ticex
[2008-09-22 18:55:42]
[ css css-reset ]
[ http://stackoverflow.com/questions/116754/best-css-reset ] [DELETED]

I'm looking for a css reset kit, but I never used one before. So which kits its out there, and whats your experiences regarding these kits?

And, is its any different between these kits, something you need to think about?

Related: Is it ok to use a css reset stylesheet? [1]

(1) 'eh, personally I only use one when necessary. For the majority of the sites I work on, I am perfectly happy with however the browser does things by default. I only mention this to say that whether or not you need it (and probably which one you choose) depends on your specific situation and needs. - Brad
cssreset.com links to the most popular reset stylesheets, along with documentation and explanations from the creators about how they came about. This is probably the best starting point. - Blazemonger
[+216] [2008-09-22 18:59:40] Justin Poliey [ACCEPTED]

I use Eric Meyer's CSS reset [1], as do many other people. It's even the reset script that Blueprint CSS [2] uses. Yahoo also has one, Reset CSS [3]. I myself am a fan of Blueprint. There's not much of a difference between these kits, because they all do pretty much the same thing: apply standard rules to elements, and eliminate cross-browser inconsistencies.

[1] http://meyerweb.com/eric/tools/css/reset/
[2] http://www.blueprintcss.org
[3] http://yuilibrary.com/yui/docs/cssreset/

(23) And most of them are just based on Eric Meyer's reset anyway. - Sam Murray-Sutton
(3) unfortunately all of them need to be updated with HTML5 elements. Especially the new block level elements like header footer article section and nav - zzzzBov
(35) Eric Meyer's reset stylesheet does have a newer version with HTML5 elements listed... he just forgot to update the page linked. The newer one is at meyerweb.com/eric/thoughts/2011/01/03/reset-revisited - ssokolow
(1) Just to point out, Yahoo's Base CSS is not a reset, but they have one too (mentioned in the post below). The biggest difference between those two is that Eric Meyer's one is more radical as it resets all the gaps and borders (to the extent possible) and all default font properties using font:inherit, but this also means it doesn't work well in IE ≤ 7. - Adam
@Adam: you shouldn't use relative positioning when referring to other posts (eg the post below). As of now, posts can be sorted three ways (active, oldest, votes), so a person would need to read all posts to determine. Furthermore, imagine if this post was no longer selected as the answer, then the post below may no longer actually be below. - vol7ron
(1) @vol7ron: I thought of that, in this case I supposed the order will not change. But Yes, to be sure, I should have referred the post using its link, thanks for the notice. - Adam
(1) @Adam: just saw you're relatively new, so wanted to let ya know. cheers - vol7ron
1
[+24] [2008-09-22 19:00:00] public static

Well there are two popular ones:

http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/

http://developer.yahoo.com/yui/reset/

I personal use YUI's version, but I've seen both used quite frequently.


(1) As knight mentions in his answer, the reset-reloaded is the older link. - HRJ
2
[+18] [2008-09-22 19:01:30] b3.

Thanks to @ssokolow for providing an updated link to Eric Meyer's reset script:

http://meyerweb.com/eric/tools/css/reset/

I've removed the copy and paste of the old script.


3
[+17] [2011-03-16 01:04:11] Vina

You can compare many of CSS resets in { CSS:resetr } site: http://cssresetr.com/ and you can also use normalize CSS [1] which will render all element consistently in all browser.

[1] http://necolas.github.com/normalize.css/

4
[+16] [2011-01-08 21:18:58] ssokolow

Eric Meyer's is good, but I'd probably go with the superset [1] of it provided by HTML5 Boilerplate [2]. (Update: The link now points to an old revision. HTML5 Boilerplate now uses normalize.css [3])

It's the only one I've seen which does more than just setting vertical-align to make display of input fields consistent. (In my experience, anything QtWebKit-based is likely to misinterpret the dimensions, positioning, font settings, etc. for native-themed widgets embedded in rendered pages)

[1] https://github.com/h5bp/html5-boilerplate/blob/e9f342b91fc66aec3e51a8f86ec1d80d531596ad/css/style.css
[2] http://html5boilerplate.com/
[3] https://github.com/necolas/normalize.css/

(9) Since v2.0 HTML5 boilerplate uses normalize.css. This is my favorite at the moment. - To1ne
This one is the most up-to-date. - styu
Link to "superset" in this comment doesn't work any longer, please update. - Emil Stenström
I suggest using normalize.css. This is the newest and included in html5 boilerplate the defacto standard template for modern development. You will probably end up adding back some of the default styles with the other brain dead resets. - Andy
5
[+14] [2008-09-22 18:57:38] Aaron Maenpaa

I like this one [1], it's four lines long:

* {
    padding:0;
    margin:0;
}
[1] http://leftjustified.net/journal/2004/10/19/global-ws-reset/

(22) This is a really heavy procedure on some older hardware. It can make large pages really sluggish and clunky to load. - Oli
(10) @Oli - I have heard this, but where is the evidence and proof? Is this a matter of clock cycles or miliseconds? - Christopher Altman
(6) Use efficient CSS selectors: code.google.com/speed/page-speed/docs/… - Török Gábor
(5) Actually guys, this answer is perfectly valid. There's no way to do it more efficiently. If you purposefully mean to target EVERY single element, then this is the way to do it. Writing out every single element manually would be a pain for you and a pain for the browser's parser. - trusktr
On the other hand, if you are resetting only ONE specific element among many similar elements, then this is when you need to use efficient selectors. This answer is a perfectly valid answer in order to reset EVERYTHING. There's no way to do it more efficiently. If you are aiming to reset EVERYTHING, then all other methods WILL use more resources... Really, it depends on your goal.... Besides, most people don't develop with old hardware in consideration. - trusktr
6
[+4] [2008-09-22 19:07:01] knight0323

Actually Eric Meyer's reset reloaded is his older copy. Go through the top toolbar and click "Toolbox" then find "CSS" and click that. The link should be http://meyerweb.com/eric/tools/css/reset/index.html

I've used Yahoo's Base CSS sheet but I've stuck with Meyer's reset sheet.


7
[+4] [2008-09-22 19:28:23] VoxPelli

The most important thing about a CSS reset is that it helps you getting your work done easier - therefor you should most probably build your own out of the inspiration you might be getting from already existing and out of your own conclusions about what a CSS reset should do.

My personal CSS reset is a bit different from for example Eric Mayer - but it suits me and makes me more productive which is exactly what it's supposed to do.


8
[+3] [2008-09-22 18:59:24] Nathan Peretic

The consensus, I think, is Eric Meyer's Reset stylesheet [1]. That's what I use.

Alternatively, you could create your own that resets only the basics.

[1] http://meyerweb.com/eric/tools/css/reset/index.html

9
[+3] [2008-09-22 18:59:32] nobody

I've been very happy with yahoo reset for multiple project. I also use yahoo grids and fonts.

My friends who try and use other products (blueprint etc) eventually find surprises and end up changing over to yahoo's package and being more happy.


10
[+2] [2011-01-08 08:04:58] ijasnijas
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{background:transparent;border:0;font-size:100%;margin:0;outline:0;padding:0;vertical-align:baseline}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}:focus{outline:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}

This is Eric Mayer's Reset(Compressed Version).. 'Blue Print' is alright, But while you are using BP, Disable the browser default style with Web Developer tool bar, It shows some different, but not in Eric Mayer's Reset Kit. :)


11
[+1] [2010-09-02 01:40:54] Webveloper

The best CSS reset is one that isn't used on any site I have to work with. I don't appreciate being forced to use a bunch of CSS hacks and inline styles, all because someone thought having an easier job was more important than making the site scalable and maintainable for the future. I've spent too many hours reworking code from agencies who never considered the havoc global resets might wreak when implemented in a content management system.


Agreed. CSS resets are more trouble than they are worth, and add a ton of extra needless CSS to your site that needs to be processed every pageload. - donatJ
This just isn't true. If you're gzipping your content as you should, the amount of bytes you're sending the client is negligible. The time that resets save you chasing down inconsistencies between browsers is valuable. - sidewaysmilk
My main problem is with overzealous resets like td{vertical-align:baseline;}. With <table id="foo"> and #foo tr{vertical-align:top;}, my style cannot cascade to the td tags as it should. Sure, I can use #foo tr{vertical-align:top !important;}, but that's extra code for no good reason, and may break td styles further down. Browser consistency can be achieved without breaking the normal rendering process. - Webveloper
12
[+1] [2011-11-26 11:02:07] GG.

I use the reset included in Bootstrap [1] (Twitter's CSS framework):

http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css

html,body{margin:0;padding:0;}
h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,cite,code,del,dfn,em,img,q,s,samp,small,strike,strong,sub,sup,tt,var,dd,dl,dt,li,ol,ul,fieldset,form,label,legend,button,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-weight:normal;font-style:normal;font-size:100%;line-height:1;font-family:inherit;}
table{border-collapse:collapse;border-spacing:0;}
ol,ul{list-style:none;}
q:before,q:after,blockquote:before,blockquote:after{content:"";}
html{overflow-y:scroll;font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;}
a:focus{outline:thin dotted;}
a:hover,a:active{outline:0;}
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block;}
audio,canvas,video{display:inline-block;*display:inline;*zoom:1;}
audio:not([controls]){display:none;}
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}
sup{top:-0.5em;}
sub{bottom:-0.25em;}
img{border:0;-ms-interpolation-mode:bicubic;}
button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;}
button,input{line-height:normal;*overflow:visible;}
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}
button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button;}
input[type="search"]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;}
input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;}
textarea{overflow:auto;vertical-align:top;}

And I add: a:focus,input,textarea,select{outline:0;}

[1] http://twitter.github.com/bootstrap/

(3) This isn't really just a reset. It is a hybrid of (a modified version of) reset.css and normalize.css. Everything from line 6 down is from normalize.css. - necolas
Thank you for this information. - GG.
13
[+1] [2012-04-04 18:46:20] JugularKill

use CSSesta Reset

In my humble OP:

  • Eric Meyers lacks some old school compatibility.
  • YUI is the reverse but too old school
  • Boilerplate is too interfering

A reset sheets shouldn't set standard "styles" in an attempt to rescue crappy browsers. A reset sheet should default elements to create a general playing field for typical & experimental websites.

Things like line-height, font-size or forcing vertical scroll affects conceptual design.

Display-block rarely intrudes on elements we "expect" to be block.

http://cssesta.tk Has 6 options commented out, the rest is a solid default (except for the text selection color)


14
[+1] [2012-04-23 10:04:07] Stephan

There are many good ones around, like Eric Meyer's Reset stylesheet:

http://meyerweb.com/eric/thoughts/2011/01/03/reset-revisited/

But I think the best practice is to write your own CSS reset file, because you know best which elements and styles you want to reset and which ones you don't mind to be as they are.

Have a look at the most common CSS-reset files and then copy & paste the styles you want to set in your own file.

Here is a link to my reset approach:

http://www.htmltweaks.com/Reset_Browser-Specific_CSS_Styles


15
[0] [2008-09-22 19:14:57] Vasil

I use Blueprint css. But I never use it just for reset. It's the best help I can get for doing a quick layout of a site.


16
[0] [2011-01-19 14:11:17] John Catterfeld

I always use a css reset, and if I'm using a third party one I always go a for the Yahoo! hosted stylesheet [1] (mainly because I'm guessing it is the most popular and will be cached on a few visitor's browsers).

I have just come across this website though which might be useful - http://www.cssreset.com

[1] http://developer.yahoo.com/yui/3/cssreset/

17
[0] [2012-01-11 06:30:00] Spadilha

I use this one:

* { 
    margin:0; padding:0; border:0; 
    outline:0; vertical-align:baseline; font-family:'FontName';
}

This does not cover the complete needs of a reset by a long shot.... - cale_b
18
[0] [2012-04-02 15:56:13] NewUser

I use

* {
  padding: 0;
  margin: 0;
}

and Eric Mayer CSS Reset http://meyerweb.com/eric/tools/css/reset/

This makes my wok much easier


19
[0] [2012-04-16 15:18:30] polas

This is not a good code. You better go here, choose your page structure and generate web layout with CSS. It works 100% in almost all browsers except for IE 5.

Now download the generated code and extract zip file. Then, open the css file and and you will see simple code you can remake your website to work in 100%.

See CSS Layout Generator at this location [1].

Now upload your website to server. To test at Net Renederer at this location [2].

And that doesn't require any programming skills. ;)

[1] http://csslayoutgenerator.com/
[2] http://netrenderer.com

20