CSS Reset & Normalize
Two different philosophies
"Reset" and "normalize" are often used loosely as synonyms, but they historically describe two different approaches to the same problem:
Reset (e.g. Eric Meyer’s Reset) | Normalize (e.g. normalize.css) | |
|---|---|---|
Philosophy | Strip almost all default styling to a flat, blank baseline | Make defaults consistent across browsers, while keeping sensible baseline styling |
Headings |
|
|
Lists | Bullets and indentation removed entirely | List styling largely preserved |
Work required after | You must explicitly restyle nearly everything, even basic hierarchy | Less follow-up work — you're adjusting a reasonable baseline, not building one from zero |
Eric Meyer's classic reset (2007-era) is the canonical example of the first philosophy — a short stylesheet that zeroes out margin, padding, borders, font-size and font-weight across a long list of elements, giving every browser an identical, mostly unstyled starting point:
/* Eric Meyer's Reset CSS v2.0 (excerpt) */
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, 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;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}sup/sub vertical alignment, or the tricky default sizing of button and input elements across browsers.The modern minimal reset
Today, most projects use neither of the above in full. Modern evergreen browsers are already far more consistent with each other than they were in 2007, so the current trend is a short, curated "modern CSS reset" that fixes only the handful of defaults that still reliably cause friction:
/* A compact modern reset */
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
}
html {
-webkit-text-size-adjust: 100%;
}
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
img, picture, video, canvas, svg {
display: block;
max-width: 100%;
}
input, button, textarea, select {
font: inherit;
}
p, h1, h2, h3, h4, h5, h6 {
overflow-wrap: break-word;
}
#root, #__next {
isolation: isolate;
}box-sizing: border-boxeverywhere — makeswidth/heightinclude padding and border, which is almost always what you actually want when sizing boxes.margin: 0on every element — removes inconsistent/surprising default margins (like the classic default<h1>margin) so spacing is something you opt into deliberately.img { max-width: 100%; display: block }— prevents images from overflowing their container and removes the small inline-baseline gap images get by default.font: inheriton form controls — form elements don't inherit typography by default in most browsers, which this fixes in one line.