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.

What the core rules fix
RuleBrowser default it replacesWhy change it
box-sizing: border-boxcontent-boxWidth then includes padding and border
margin: 0Margins on body, headings, p, listsSpacing comes only from your own CSS
line-height: 1.5 on bodynormal (roughly 1.2)Easier reading for paragraphs
img { display: block; max-width: 100% }Inline, natural widthNo gap below images, no overflow
font: inherit on inputs and buttonsSystem font at a small sizeForms 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;
  }
}

Reset, normalize or nothing

Three ways to handle browser defaults
ApproachWhat it doesGood for
Classic hard resetStrips almost every default, including heading sizesRarely needed today
normalize.cssKeeps defaults, fixes cross-browser differencesContent sites that like default typography
Short modern resetFixes sizing, margins, media and forms onlyMost new sites and apps
Framework reset (Tailwind Preflight)Ships with the frameworkProjects 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

  1. Read the note beside each rule, then switch it on or off.
  2. Choose whether to wrap the output in @layer reset so any of your own rules beat it without a fight.
  3. Copy the generated CSS and load it before your other stylesheets.

Tips

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

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap