CSS Weekly

Archives
Sponsor
June 1, 2026

CSS Weekly #8: Modern CSS Reset & Normalize Techniques

CSS Weekly #8: Modern CSS Reset & Normalize Techniques 🔄

Hey sheinhardt@example.com,

CSS resets have evolved! Let's explore modern approaches that enhance rather than destroy browser defaults.

The Evolution of Resets

  1. 2004: Universal selector * { margin: 0; padding: 0; }
  2. 2007: Eric Meyer's Reset CSS
  3. 2011: Normalize.css
  4. 2023: Modern, minimal resets

Let's build a modern reset together!

🎯 A Modern CSS Reset

Here's my go-to reset for 2024:

/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margin */
body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
  margin: 0;
}

/* Set core root defaults */
html:focus-within {
  scroll-behavior: smooth;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  line-height: 1.5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 
               'Segoe UI', Roboto, sans-serif;
}

/* Remove list styles on ul, ol with class */
ul[class],
ol[class] {
  list-style: none;
  padding: 0;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
}

/* Make images easier to work with */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
}

/* Remove all animations and transitions for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
   scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

Beyond Basic Resets

1. Modern Form Reset

/* Better form defaults */
button,
input,
select,
textarea {
  background-color: transparent;
  border: 1px solid WindowFrame;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  padding: 0.25em 0.375em;
}

/* Remove spinner from number inputs */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Better select styling */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1em;
  padding-right: 2rem;
}

/* Remove default button styling */
button {
  background-color: transparent;
  border: 0;
  cursor: pointer;
}

2. Better Typography Defaults

/* Fluid typography */
:root {
  --fluid-min-width: 320;
  --fluid-max-width: 1140;

  --fluid-screen: 100vw;
  --fluid-bp: calc(
    (var(--fluid-screen) - var(--fluid-min-width) / 16 * 1rem) /
    (var(--fluid-max-width) - var(--fluid-min-width))
  );
}

@media screen and (min-width: 1140px) {
  :root {
    --fluid-screen: calc(var(--fluid-max-width) * 1px);
  }
}

/* Fluid type scale */
h1 {
  font-size: clamp(
    2rem,
    calc(2rem + (3 - 2) * var(--fluid-bp)),
    3rem
  );
}

/* Better line heights */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
}

p {
  line-height: 1.6;
}

/* Balanced text wrapping */
h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

3. Modern Layout Helpers

/* Stack layout primitive */
.stack > * + * {
  margin-block-start: var(--space, 1rem);
}

/* Cluster layout */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space, 1rem);
  align-items: center;
}

/* Auto grid */
.auto-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(var(--min, 250px), 1fr)
  );
  gap: var(--space, 1rem);
}

/* Container */
.container {
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--gutter, 1rem);
  max-width: var(--max-width, 75rem);
}

🚀 CSS Layers for Organization

Use cascade layers to organize your reset:

@layer reset, defaults, patterns, components, utilities;

@layer reset {
  /* Reset styles here */
}

@layer defaults {
  /* Default element styles */
  :root {
    --primary: #0066cc;
    --body-font: system-ui, sans-serif;
  }

  body {
    font-family: var(--body-font);
    color: var(--text, #333);
  }
}

@layer utilities {
  /* Utility classes that should win */
  .mt-0 { margin-top: 0 !important; }
}

Accessibility Focused Reset

/* Focus styles */
:focus {
  outline: 2px solid var(--primary, blue);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
}

.skip-link:focus {
  left: 50%;
  transform: translateX(-50%);
  top: 1rem;
  background: white;
  padding: 1rem;
  text-decoration: none;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast support */
@media (prefers-contrast: high) {
  :root {
    --primary: #0000ff;
    --text: #000000;
    --background: #ffffff;
  }
}

Putting It All Together

Save this as modern-reset.css:

/* 
  Modern CSS Reset
  Version: 1.0
  License: MIT
*/

@layer reset {
  /* Include all the reset rules from above */
}

/* Custom properties for flexibility */
:root {
  /* Colors */
  --color-primary: #0066cc;
  --color-text: #333333;
  --color-background: #ffffff;

  /* Typography */
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', monospace;

  /* Spacing */
  --space-xs: clamp(0.75rem, 2vw, 1rem);
  --space-sm: clamp(1rem, 3vw, 1.5rem);
  --space-md: clamp(1.5rem, 4vw, 2rem);
  --space-lg: clamp(2rem, 6vw, 3rem);
  --space-xl: clamp(3rem, 8vw, 4rem);
}

Sponsored by Modern CSS Solutions - Learn modern CSS techniques from Stephanie Eckles. Use code CSSWEEKLY for 25% off!

Next week: Responsive Typography with clamp()!

— Sarah from CSS Weekly

P.S. What's in your CSS reset? Reply and share your approach!

Unsubscribe | Suggest a topic

← Newer CSS Weekly #9: Responsive Typography with clamp() Older → CSS Weekly #7: Performance Optimization Tips

Add a comment:

Powered by Buttondown, the easiest way to start and grow your newsletter.