CSSBest-PracticesFrontend

A Guide to a Modern CSS Reset (2026 Edition)

3.475 min read
Md Nasim SheikhMd Nasim Sheikh
Share:

Every project starts the same way: fighting the browser's default agent styles. Margins on <body>, box-sizing: content-box, and weird font sizing.

Here is a battle-tested, minimal reset for modern web development.

Advertisement

The Reset Code

/* 1. Use a more intuitive box-sizing model. */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Remove default margin */
* {
  margin: 0;
}

/* 3. Allow percentage-based heights in the application */
html, body {
  height: 100%;
}

/* 4. Improve typography defaults */
body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 5. Improve media defaults */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

/* 6. Inherit fonts for form controls */
input, button, textarea, select {
  font: inherit;
}

/* 7. Avoid text overflows */
p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

Deep Dive: Why box-sizing: border-box?

By default, CSS uses content-box. If you set width: 100px and padding: 20px, the actual rendered width is 140px (100 + 20 + 20).

With border-box, width: 100px means the final width is 100px, and the padding pushes the content inward. This makes responsive design mathematically possible.

Deep Dive: Media Defaults

img tags are inline by default, which causes a mysterious "gap" at the bottom of images (due to line-height). Setting display: block fixes this instantly.

img {
  display: block;
  max-width: 100%; /* Prevent horizontal scrolling */
}

Advertisement

Test Your Knowledge

Quick Quiz

Why is 'box-sizing: border-box' preferred over the default 'content-box'?

Conclusion

You don't need a heavy library like Normalize.css anymore. Browsers are much more consistent today. A small 20-line snippet is usually enough to standardize your baseline.

Md Nasim Sheikh
Written by

Md Nasim Sheikh

Software Developer at softexForge

Verified Author150+ Projects
Published:

You May Also Like