snippetcssTippending
CSS modern reset and base styles
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:
Each rule explained:
/* 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 widthmargin: 0: remove default margins100svh: small viewport height (mobile-friendly)font: inheriton inputs: match body fontoverflow-wrap: prevent text overflowisolation: 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.