Which HTML5 reset CSS do you use and why?

91,908

Solution 1

Real talk: Despite the markdowns kaikai is right, you only need to reset *padding & margin to 0.

Though unfortunately 99% of us do not have resources or man power to keep up with the hundreds of browser versions out there. So a reset sheet is essential for the typical website.

html5reset: (It's too interfering)

I just took a look at http://html5reset.org/

img,
object,
embed {max-width: 100%;}

And:

html {overflow-y: scroll;}

I understand it has good intentions but, that's not the job of a reset sheet. It's making too many assumptions.

BluePrint Reset:(literally a blueprint)

body {
  line-height: 1.5;
  background: white;
}

Whats up with 1.5. And why background white?(I know it's for correcting but still not necessary)

Normalize.css: (Not normal)

https://github.com/necolas/normalize.css/blob/master/normalize.css

It started good with some webkit/ie hacks but

h1 {
    font-size: 2em;
    margin: 0.67em 0;
}

h2 {
    font-size: 1.5em;
    margin: 0.83em 0;
}

h3 {
    font-size: 1.17em;
    margin: 1em 0;
}

h4 {
    font-size: 1em;
    margin: 1.33em 0;
}

h5 {
    font-size: 0.83em;
    margin: 1.67em 0;
}

h6 {
    font-size: 0.75em;
    margin: 2.33em 0;
}

Every header tag is targeted. & they don't reset the line-height of the body.

I'm sure all the above does the intended job well, but will probably be overridden more than necessary.

Eric Meyer

YUI

HTML5Boilerplate

The above are more for pros with Boilerplate leaning to the (over friendly) side I'm sure due to popularity. At the moment 80% of my customized reset is boilerplate.

I'm going to go though all three bit by bit and make my own, it's not rocket science.

Solution 2

Normalize.css is great for both desktop and mobile browsers and is used in many popular HTML templates.

But what about using the CSS all property which resets CSS properties except direction and unicode-bidi? That way you don't need to include any additional files:

{
    all: unset
}

CSS all has wide support except in IE/Edge. Similarly with unset.

Solution 3

The reset.css used by Blueprint CSS framework works well and includes HTML5 elements. It gets included in their screen.css file.

Blueprint is a useful resource for rapid prototyping of new sites, and their source code is well organized and worth learning from.

Solution 4

  1. Preserves useful defaults, unlike many CSS resets.
  2. Normalizes styles for a wide range of HTML elements.
  3. Corrects bugs and common browser inconsistencies.
  4. Improves usability with subtle improvements.
  5. Explains what code does using detailed comments.

normalize.css

Solution 5

Eric Meyer also released v2 of his CSS reset (and he did so almost a year ago now):

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

Share:
91,908
penetra
Author by

penetra

I am a website and web application developer in Calgary, Alberta. I have been doing backend web development in PHP and frontend in HTML/CSS/JavaScript for over 20 years. My specialties are Symfony, Vue, Event Sourcing & CQRS, Craft CMS, WordPress. I've built everything from basic basic brochure style websites to heavily trafficked eCommerce site and social platforms to internal applications.

Updated on July 08, 2022

Comments

  • penetra
    penetra almost 2 years

    Which HTML5 reset CSS do you use and why? Is there one that you've found to cover more cases?

    I've started using HTML5 Doctor's: http://html5doctor.com/html-5-reset-stylesheet/ It seems to work, but I'm wondering if there is something better out there.

  • Quentin
    Quentin almost 14 years
    Zapping the default margin and padding on form controls can have unwelcome effects and named font-size keywords don't have entirely consistent behavior across browsers. This is overly simplistic. It also fails to set styles for elements introduced in HTML 5, so they remain display: inline.
  • kaikai
    kaikai almost 14 years
    I disagree. Margin and padding are the only unpredictable properties. The font-size property uses a named keyword to specifically target browsers who read those, which makes the YUI font scales effective across every major browser (developer.yahoo.com/yui/examples/fonts/fonts-size_source.ht‌​ml). I would also never want to impose upon the normal flow of elements and so I would leave those HTML 5 elements alone, only changing their display type or positioning as needed. I realize my choice is unpopular, but it is far more elegant than other solutions and it works.
  • Filip Dupanović
    Filip Dupanović over 13 years
    No no no no no! HTML5 elements do not have have the display property set, so they gracefully fall back to the default display: inline. Have you ever seen a site diagram where the header, footer, navigation, side columns, practically every page section flowing inline??? Sorry kaikai, but this just isn't acceptable!
  • James A Mohler
    James A Mohler over 11 years
    Do you have any additional details?
  • cornishninja
    cornishninja over 11 years
    I don't leave in elements that I'm not using ion a specific project. For example I remove form elements if I'm not using forms. I'm sure you get the idea. There's no point in resetting elements that you aren't using.
  • cornishninja
    cornishninja over 11 years
    To back up my point about modifying the reset to fit my needs: cssreset.com/which-css-reset-should-i-use
  • Icemanind
    Icemanind about 11 years
    Dude, I'm not even an HTML5 guru (yet) and I know this is totally completely not the right way to reset.
  • Anton Strogonoff
    Anton Strogonoff about 11 years
    Absolutely valid answer. The only drawback might be that * selectors are slow, I heard.
  • Ruben Verborgh
    Ruben Verborgh over 10 years
    Note that normalize.css has changed by now; font-sizes of headings are no longer set.
  • Matt Smith
    Matt Smith over 10 years
    It's all worth mentioning that Normalize.css doesn't just manage desktop browsers but also mobile browsers such as iOS Safari, Chrome for Android, stock browsers, et al., which are unique in their own right. For this reason and others Normalize is baked into many popular frameworks.
  • tomasz86
    tomasz86 over 10 years
    Interesting but it seems to be the slowest solution and supported only in Firefox, thus it's got no real use (at least at this point of time).
  • tomasz86
    tomasz86 over 10 years
    Simple yet effective, and faster than resets that rely on the * universal selector.
  • Matt Smith
    Matt Smith over 10 years
    True that only Firefox is supporting it right now but I think it has a good chance of ending up in solutions like Modernizr. github.com/Modernizr/Modernizr/issues/1219
  • skmasq
    skmasq almost 8 years
    @AntonStrogonoff Although valid answer this is part of the worst practices due to usage of * selector. This is slow and introduces hard to follow behavior of css.
  • Anton Strogonoff
    Anton Strogonoff almost 8 years
    @skmasq the question is “what reset do you use?”, and it is addressed precisely, which is why I upvoted the answer. Doesn’t matter now that it’s a community wiki. If you could clarify what hard to follow behavior would you observe in modern browsers with these CSS rules, that’d be useful!
  • Daniel Sokolowski
    Daniel Sokolowski about 7 years
    I used to use 'Eric Meyer' but now use 'YUI' reset style sheet because of this: danielsokolowski.blogspot.ca/2012/11/…