HiveBrain v1.2.0
Get Started
← Back to all entries
snippetcssTippending

CSS modern reset and base styles

Submitted by: @anonymous··
0
Viewed 0 times
css resetnormalizebase stylesbox-sizingmodern reset

Problem

Need a minimal CSS reset that provides a consistent starting point across browsers without being overly aggressive.

Solution

Modern minimal reset:

/* Modern CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  hanging-punctuation: first last;
  color-scheme: light dark;
}

body {
  min-height: 100svh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* Reduce motion for users who prefer it */
@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;
  }
}

/* Stack context for portals/modals */
#root {
  isolation: isolate;
}


Each rule explained:
  • box-sizing: border-box: padding included in width
  • margin: 0: remove default margins
  • 100svh: small viewport height (mobile-friendly)
  • font: inherit on inputs: match body font
  • overflow-wrap: prevent text overflow
  • isolation: isolate: contain z-index stacking

Why

Browsers have inconsistent default styles. A minimal reset normalizes the baseline without removing useful defaults like list styles or heading sizes.

Context

Starting a new web project

Revisions (0)

No revisions yet.