CSS: CSS Reset & Atomic CSS

🗓 Last updated: 2026-11-30👤 Written by: Blake✓ Reviewed by: Gray🏷 Category: CSS Tutorial

1. CSS Reset

Different browsers have different default styles. CSS Reset eliminates these differences for consistent rendering.

(1) Basic Reset

CSS
/* Universal reset */
*, *::before, *::after {
/* Box model properties */
  /* Box model properties */
  /* Box model properties */
  /* Box model properties */
  margin: 0;
/* Box model properties */
  /* Box model properties */
  /* Box model properties */
  /* Box model properties */
  padding: 0;
/* Box model properties */
  /* Box model properties */
  /* Box model properties */
  /* Box model properties */
  box-sizing: border-box;
}

/* Base body styles */
body {
/* Font style */
  /* Font style */
  /* Font style */
  /* Font style */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
/* Font style */
  /* Font style */
  /* Font style */
  /* Font style */
  line-height: 1.6;
/* Text color */
  /* Text color */
  /* Text color */
  /* Text color */
  color: #333;
}

/* Link reset */
a {
  text-decoration: none;
/* Text color */
  /* Text color */
  /* Text color */
  /* Text color */
  color: inherit;
}

/* Image responsive */
img {
/* Size properties */
  /* Size properties */
  /* Size properties */
  /* Size properties */
  max-width: 100%;
/* Display mode */
  /* Display mode */
  /* Display mode */
  /* Display mode */
  display: block;
}

▶ Example

A practical CSS reset combining normalization and box-sizing:

▶ Try it Yourself

(2) Normalize.css vs Reset

Approach Pros Cons
Normalize.css Preserves useful defaults, only fixes inconsistencies More complex
Full Reset Clean slate, full control Must redefine everything

Recommendation: Use Normalize.css for most projects.


2. Atomic CSS

Each class does one thing — like building blocks:

▶ Example

▶ Try it Yourself

(1) Benefits

  1. Fine-grained: Each class does one thing, flexible combinations
  2. Highly reusable: One .flex works anywhere
  3. Smaller CSS: No duplicate property declarations
  4. Safe changes: Modifying one class won't break unrelated elements

▶ Example

Building a responsive card with atomic classes:

▶ Try it Yourself

❓ FAQ

Q Why do you need a CSS reset? What happens without one?
A Browsers ship different defaults for h1 font sizes, body margins and ul padding — the same page can differ by a few pixels between Chrome and Edge. Without a reset you end up fixing compatibility page by page. One small reset at the top gives every page a predictable starting point.
Q CSS reset vs normalize — what's the difference and which should I pick?
A A traditional Reset zeroes everything (h1 ends up the same size as p), while Normalize.css keeps useful defaults and only smooths out browser inconsistencies. The more popular approach today is a modern reset: clear margin/padding and set box-sizing, leave the rest to your own styles. A hand-written minimal reset is lighter than pulling in all of Normalize.css.
Q What does a modern CSS reset look like?
A A minimal one is enough: *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } plus img { max-width: 100%; display: block; } and a { color: inherit; text-decoration: none; }. Add rules as your project needs them, e.g. ul, ol { list-style: none; } to strip list bullets.
Q Does * { box-sizing: border-box } hurt performance?
A Almost not at all. The universal selector overhead is negligible in modern browsers, and border-box makes width/height calculations exclude padding and borders, which is far more intuitive. Tailwind and Bootstrap both default to it — use it with confidence.
Q My ul bullets disappeared after the reset — how do I get them back?
A list-style: none in the reset removed them; restore locally where needed: ul.dots { list-style: disc; padding-left: 1.5em; }. Bring back the padding-left too or you lose the indent. Resetting globally and restoring on demand is exactly how a reset is meant to be used.
Q Links lost their underline and now match the text color after the reset — what do I do?
A That's a { text-decoration: none; color: inherit; } at work. Links inside buttons and navs don't need underlines, but for body copy add them back: a.text-link { color: #0969da; text-decoration: underline; } — otherwise users can't tell what's clickable.
Q When are atomic classes like .mt-20 worth using?
A Mid-to-large projects that need a design system: one .flex class reused everywhere, and spacing tweaks just change the numeric suffix. For small projects a few regular classes are simpler. The cost is long class attributes (class="flex items-center p-20 mt-10") — accept that before adopting.
Q Are atomic classes the same thing as Tailwind? Should I learn Tailwind directly?
A Same idea — one class controls one property — Tailwind just packages it into a full framework. Write a dozen atomic classes by hand first to get the concept, then pick up Tailwind; debugging and custom spacing values will make sense. Memorizing class names alone works until you hit a customization request.
Q Should reset.css come before all other styles? What if it's loaded in the wrong order?
A Always load it first. margin: 0 in the reset has the same specificity as later rules and the last one wins — if the reset loads after component styles it wipes out spacing you already set. Link order: reset.css → atomic/component styles → page styles.

📖 Summary

📝 Exercises

  1. Create a reset.css file with: universal margin/padding/box-sizing reset, body base font/color, link style reset, responsive images.
  2. Add at least 10 common atomic classes to reset.css (flex, spacing, text alignment, etc.).
  3. Create an HTML page using only atomic classes from reset.css for a simple card layout (title, text, image).
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏