Skip to content

Instantly share code, notes, and snippets.

@MrGrigri
Last active June 19, 2025 17:25
Show Gist options
  • Save MrGrigri/203ff2f7f60a1b1b899ff756c7d4db33 to your computer and use it in GitHub Desktop.
Save MrGrigri/203ff2f7f60a1b1b899ff756c7d4db33 to your computer and use it in GitHub Desktop.
Modern CSS Reset
@layer reset {
:root {
--_body-font-family: var(--reset-body-font-family, sans-serif);
--_heading-font-family: var(--reset-heading-font-family, serif);
--_code-font-family: var(--reset-code-font-family, monospace);
--_text-max-width: var(--reset-text-max-width, 65ch);
--_details-duration: var(--reset-details-duration, 175ms);
--_details-timing: var(--reset-details-timing, ease-out);
}
:is(*) {
min-inline-size: 0;
}
:is(*, *::before, *::after) {
box-sizing: inherit;
}
:is(html) {
font-family: var(--_body-font-family);
text-size-adjust: none;
box-sizing: border-box;
interpolate-size: allow-keywords;
}
:is(body) {
margin: 0;
min-height: 100dvh;
line-height: 1.5;
}
:is(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd) {
margin-block-start: 0;
}
:is(h1, h2, h3, h4, h5, h6, button, input, label) {
line-height: 1;
}
:is(h1, h2, h3, h4, h5, h6) {
font-family: var(--_heading-font-family);
text-wrap: balance;
}
:is(hr) {
border: none;
border-block-end: 1px solid;
inline-size: 100%;
}
:is(p, li, figcaption) {
text-wrap: pretty;
max-width: var(--_text-max-width);
}
:is(fieldset) {
border-style: solid;
border-width: 1px;
margin: 0;
}
:is(legend) {
padding-inline: 1ch;
}
:is(input, button, textarea, select) {
font-family: inherit;
font-size: inherit;
}
:is(button, select):not(:disabled) {
cursor: pointer;
}
:is(a:not([class])) {
text-decoration: underline;
}
:is(ul[role="list"]:not([class]), ol[role="list"]):not([class]) {
list-style-type: "";
margin: 0;
padding: 0;
}
:is(blockquote, menu) {
margin: 0;
padding: 0;
}
:is(img, picture) {
max-width: 100%;
display: block;
}
:is(code, pre, kbd) {
font-family: var(--_code-font-family);
}
:is(table, math, time[datetime*=":"]) {
font-variant-numeric: tabular-nums lining-nums;
}
:is(table) {
border-collapse: collapse;
}
:is(summary) {
cursor: pointer;
}
:is(:target) {
scroll-margin-block-start: 5rlh;
}
@media (prefers-reduced-motion: no-preference) {
:is(html) {
scroll-behavior: smooth;
}
:is(details) {
interpolate-size: allow-keywords;
&::details-content {
block-size: 0;
overflow-y: clip;
transition-property: content-visibility, block-size;
transition-duration: var(--_details-duration);
transition-timing-function: var(--_details-timing);
transition-behavior: allow-discrete;
}
&[open] {
&::details-content {
block-size: auto;
@starting-style {
opacity: 0;
block-size: 0;
}
}
}
}
}
}
@layer reset {
/*
Josh's Custom CSS Reset
https://www.joshwcomeau.com/css/custom-css-reset/
*/
/* Modified by Michael Richins */
:where(*, *::before, *::after) {
box-sizing: border-box;
}
:where(*) {
margin: 0;
font-size: unset;
}
:where(html, body) {
margin: 0;
min-block-size: 100vh;
min-block-size: 100dvh;
scroll-behavior: smooth;
}
:where(body) {
line-height: 1.5;
font-smooth: always;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
:where(img, picture, video, canvas, svg) {
display: block;
max-inline-size: 100%;
}
:where(ul[role='list'], ol[role='list']) {
list-style: none;
}
:where(input, button, textarea, select) {
font: inherit;
}
:where(p, h1, h2, h3, h4, h5, h6) {
overflow-wrap: break-word;
}
:where(h1, h2, h3, h4, h5, h6) {
text-wrap: balance;
}
:where(a:not([class])) {
text-decoration-skip-ink: auto;
color: currentColor;
}
@media (prefers-reduced-motion: reduce) {
:where(*) {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment