Modern CSS Reset (Annotated)
A modern CSS reset is a dozen or so short rules placed before your own styles: border-box sizing on every element, zero default margins, a readable line height, block-level images capped at their container width, and form controls that inherit your font. Pick the rules you want below, then copy the result.
| Rule | Browser default it replaces | Why change it |
|---|---|---|
| box-sizing: border-box | content-box | Width then includes padding and border |
| margin: 0 | Margins on body, headings, p, lists | Spacing comes only from your own CSS |
| line-height: 1.5 on body | normal (roughly 1.2) | Easier reading for paragraphs |
| img { display: block; max-width: 100% } | Inline, natural width | No gap below images, no overflow |
| font: inherit on inputs and buttons | System font at a small size | Forms match the rest of the page |
Updated
Copying a reset you do not understand means debugging rules you never chose. This page explains each line in plain words and lets you build your own version with switches, so the file you paste is short and every line is there for a reason.
Reset builder
Default selection, wrapped in a cascade layer:
@layer reset {
/* Width and height include padding and border. */
*, *::before, *::after {
box-sizing: border-box;
}
/* Spacing comes only from your own rules. */
* {
margin: 0;
}
/* A taller line height and full-height body. */
body {
min-height: 100vh;
line-height: 1.5;
}
/* No baseline gap under images and no overflow. */
img, picture, video, canvas, svg {
display: block;
max-width: 100%;
}
/* Inputs and buttons match surrounding text. */
input, button, textarea, select {
font: inherit;
}
/* Long URLs wrap instead of overflowing. */
p, h1, h2, h3, h4, h5, h6 {
overflow-wrap: break-word;
}
/* Even line lengths for short headings. */
h1, h2, h3, h4, h5, h6 {
text-wrap: balance;
}
}- Border-box sizing: Width and height include padding and border.
- Remove default margins: Spacing comes only from your own rules.
- Readable body text: A taller line height and full-height body.
- Block, responsive media: No baseline gap under images and no overflow.
- Forms inherit the font: Inputs and buttons match surrounding text.
- Break long words: Long URLs wrap instead of overflowing.
- Balanced headings: Even line lengths for short headings.
- No orphan words: Avoids one word alone on a paragraph's last line.
- Isolate the app root: A fresh stacking context so z-index in the app cannot fight portals.
- Smooth anchor scrolling: Only for visitors who have not asked for less motion.
Reset, normalize or nothing
| Approach | What it does | Good for |
|---|---|---|
| Classic hard reset | Strips almost every default, including heading sizes | Rarely needed today |
| normalize.css | Keeps defaults, fixes cross-browser differences | Content sites that like default typography |
| Short modern reset | Fixes sizing, margins, media and forms only | Most new sites and apps |
| Framework reset (Tailwind Preflight) | Ships with the framework | Projects already on that framework |
Before and after
A card with and without border-box
Both boxes say width: 200px. Only the second keeps that width once padding and border are added.
<style>
.box { width: 200px; padding: 20px; border: 6px solid #2563eb; margin: 8px 0; background: #eff6ff }
.sized { box-sizing: border-box }
</style>
<div class="box">content-box: 252px wide</div>
<div class="box sized">border-box: 200px wide</div>
Why box-sizing comes first
With the default content-box, a 300px wide card with 20px padding ends up 340px wide. border-box folds padding and border into the width you wrote, which is how most people expect sizing to behave.
Applying it to the ::before and ::after pseudo-elements as well keeps decorative shapes consistent with the boxes they decorate.
Text rules that age well
text-wrap: balance evens out the line lengths of short headings, and text-wrap: pretty avoids a single orphan word on the last line of a paragraph. Browsers that do not know these values simply ignore them, so they are safe to include.
overflow-wrap: break-word lets a long URL or code token break instead of pushing the page sideways on a phone.
What a reset should not do
A reset is not a design system. Colours, font families and spacing scales belong in your own base layer, where they can be changed without touching the reset.
Avoid rules that hurt accessibility, such as outline: none on everything or removing all animation for every visitor. Motion settings belong in a prefers-reduced-motion query.
How it works
- Read the note beside each rule, then switch it on or off.
- Choose whether to wrap the output in @layer reset so any of your own rules beat it without a fight.
- Copy the generated CSS and load it before your other stylesheets.
Tips
- Put the reset in a cascade layer. Styles outside any layer beat layered ones regardless of specificity.
- Do not reset list-style on every ul. Tailwind's docs warn that VoiceOver may not announce unstyled lists as lists, so add role="list" to any list you strip.
- Leave the focus outline alone in a reset. Restyle it per component instead of removing it globally.
- If you use Tailwind, you already have a reset called Preflight, so a second one usually just adds noise.
Frequently asked questions
What is the difference between a CSS reset and normalize.css?
A reset removes browser defaults so you start from a nearly blank page. normalize.css keeps useful defaults and only corrects the places where browsers disagree. Many current resets sit in between: they keep headings bold and lists intact but drop margins and fix sizing.
Do I still need a CSS reset in 2026?
Browsers agree far more than they did, so the old giant resets are unnecessary. A short one is still worth having, because defaults such as content-box sizing, body margin and inline images are rarely what a layout wants.
Why use :where() in a reset?
:where() has zero specificity, so any later selector, even a bare element selector, overrides the reset. That stops reset rules from quietly winning over component styles.
Where do I put the reset?
Load it first, before any other stylesheet, or import it inside @layer reset at the top of your main CSS file and declare the layer order once with @layer reset, base, components.
Related: CSS box model and display, CSS selectors cheat sheet, Modern CSS features, BEM and CSS naming conventions, CSS minifier.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
More in Guides
- CSS Scroll Snap: Carousels and Full-Page Sections
- CSS Selectors Cheat Sheet With a Live Tester
- CSS Sizing Functions: calc(), min(), max(), clamp() and Viewport Units
- CSS Text Overflow: Ellipsis, Line Clamp and Word Breaking
- CSS Text Styling: Fonts, Size, Weight, Underline, Alignment
- CSS Transforms: Rotate, Scale, Translate and Skew
- CSS Transitions and Keyframes, With 20 Copyable Examples
- CSS Variables: From var() to Themes and @property
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App