Rendering defaults and fallbacks
html {
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-synthesis: none;
-moz-text-size-adjust: none;
-webkit-text-size-adjust: none;
text-size-adjust: none;
}
body {
font-size-adjust: from-font;
}
font-synthesis: none blocks the browser from fabricating bold or italic faces the family doesn't ship. The smoothing and text-rendering hints mostly target WebKit and remain platform-dependent. text-size-adjust turns off mobile font inflation that would distort a deliberately fixed layout on rotation, while font-size-adjust: from-font leans on font metrics to limit the visible size shift during a fallback-to-webfont swap.
This :root block is an excerpt; the finished stylesheet combines it with custom properties declared later.
Sizing type to the container, not the viewport
A viewport-relative clamp() has no idea how wide its own container is, so a heading inside a narrow sidebar can balloon as if it filled the screen.
.article-container {
container-type: inline-size;
}
:root {
--step-0: clamp(1rem, 0.9rem + 1cqi, 1.125rem);
--step-3: clamp(2rem, 1.6rem + 3cqi, 2.75rem);
}
Declaring container-type: inline-size on the wrapper turns it into a container query context, exposing the cqi unit to its children. Swapping vw for cqi inside clamp() lets one heading rule scale sensibly in an article column or a 300px sidebar, with no per-component media queries.
Half-leading and vertical rhythm
:heading, p, blockquote, figcaption, li {
text-box-trim: trim-both;
text-box-edge: cap alphabetic;
/* shorthand: text-box: trim-both cap alphabetic; */
}
line-height bundles space above the cap height and below the baseline. That half-leading becomes visible the moment text has to butt up tightly against another element. text-box-trim removes it, and text-box-edge measures from capital letters to the alphabetic baseline—a metrics-aware replacement for font-specific negative-margin hacks.
@supports selector(:heading) {
:heading {
text-box: trim-both cap alphabetic;
}
}
Selectors Level 5 proposes :heading to match h1–h6 plus [role="heading"]. Since no browser ships it yet, gate it behind @supports selector().
Wrapping rules for headings and body copy
:heading, blockquote, figcaption {
text-wrap: balance;
}
p, li, dd {
text-wrap: pretty;
max-width: 65ch;
}
[contenteditable="true"] {
text-wrap: stable;
}
Uncontrolled heading wrapping can strand a single short last line; text-wrap: balance spreads text evenly across lines and works best up to roughly six lines. Paragraphs do better with text-wrap: pretty, which prevents an orphaned final word without rebalancing the whole block. Both retire JavaScript orphan fixers. Text inside editable regions needs text-wrap: stable so new words don't reshuffle the paragraph.
Hyphenation with limits
<html lang="en-GB">
p {
hyphens: auto;
}
hyphens: auto depends on the browser's language dictionaries, so the document must carry a correct lang (e.g. <html lang="en-GB">); without it there is nothing to hyphenate against. Even with the right language, defaults can produce tiny fragments or a run of consecutive hyphenated lines.
p {
hyphens: auto;
hyphenate-limit-chars: 6 3 3; /* word length, min before break, min after break */
hyphenate-character: "‐"; /* use proper hyphen glyph instead of dash */
hyphenate-limit-lines: 2; /* no more than 2 consecutive hyphenated lines */
hyphenate-limit-zone: 8%; /* reduce overall hyphenation frequency */
hyphenate-limit-last: always; /* never hyphenate the last word of a paragraph */
/* Safari legacy equivalents */
-webkit-hyphens: auto;
-webkit-hyphenate-limit-before: 4;
-webkit-hyphenate-limit-after: 3;
-webkit-hyphenate-limit-lines: 2;
}
pre, code, var, samp, kbd, :heading {
hyphens: manual;
-webkit-hyphens: manual;
}
hyphenate-limit-chars sets the minimum breakable word and fragment sizes, and hyphenate-limit-lines stops the ladder effect. hyphenate-limit-zone reduces how often breaks occur, and hyphenate-limit-last shields the final word. Safari requires the prefixed equivalents, so both sets must be declared together.
- Force
hyphens: manualon code, variables, and headings—a split code token can change its meaning, and a hyphenated heading usually reads as a mistake.
Hanging punctuation and underlines that respect the glyphs
blockquote, p {
hanging-punctuation: first allow-end last;
}
a {
text-decoration-thickness: from-font;
text-underline-offset: 0.15em;
text-decoration-skip-ink: auto;
}
Punctuation carries less visual weight than letters, so an opening quotation mark aligned with the line's edge looks slightly inset relative to the text beneath. hanging-punctuation pushes the specified marks fractionally past the block edge: first covers opening punctuation, last covers closing marks at the end of a block, and allow-end lets punctuation hang past the right edge instead of forcing a wrap. The edges then read as truly flush.
Underlines suffer a similar problem, since browsers apply a uniform thickness and position regardless of the font's weight. text-decoration-thickness: from-font takes the thickness the designer intended, text-underline-offset clears the descenders, and text-decoration-skip-ink: auto breaks the line wherever a descender crosses it.
Variable-font tuning
body {
font-optical-sizing: auto;
font-variant-ligatures: common-ligatures contextual;
font-kerning: normal;
}
/* Dark mode grade compensation */
:root {
--vf-grad: 0;
}
@media (prefers-color-scheme: dark) {
:root { --vf-grad: -50; }
}
* {
font-variation-settings: "GRAD" var(--vf-grad, 0);
}
The optical size axis, opsz, lets a typeface thin its strokes at display sizes and thicken them for small text. font-optical-sizing: auto applies that adjustment automatically based on rendered size. The @supports rule handles the older font-variation-settings syntax some browsers still need, and font-variant-ligatures and font-kerning switch on the font's own ligatures and kerning pairs.
Because light text on dark reads heavier than the same weight on light, a font with a GRAD (grade) axis can have that perceived weight dialed down in dark mode via that axis—no change to glyph shape or width, as a real weight switch would cause. Fonts without a GRAD axis simply ignore it.
@font-face {
font-family: "Mono";
src: url("/fonts/mono-var.woff2") format("woff2");
size-adjust: 105%; /* tune per-font */
}
Dropping a mono font into prose often reveals a mismatched x-height at the same font-size. Setting size-adjust once in @font-face scales only that font's rendered output while leaving the font-size value alone.
Numbers, emoji, and script-aware details
Table digits need equal widths to form a clean column; digits in running prose do not and should sit naturally with the words around them.
table, .tabular {
font-variant-numeric: tabular-nums lining-nums;
}
.prose {
font-variant-numeric: oldstyle-nums proportional-nums;
}
.emoji-color {
font-variant-emoji: emoji;
}
.emoji-mono {
font-variant-emoji: text;
}
tabular-nums and lining-nums give table figures fixed widths and full cap height. oldstyle-nums and proportional-nums keep digits alongside lowercase without breaking the sentence's texture.
font-variant-emoji makes the color-vs-monochrome choice explicit instead of leaving it to browser or platform fallback, where results vary widely. Target the .emoji-color and .emoji-mono classes at containers rather than applying either globally.
Locale quotes and true sub/superscripts
Quote style and nesting order are language- and region-dependent: English nests single inside double, British English does the reverse, and French uses guillemets with a thin space.
:where(:lang(en)) > * { quotes: "\"" "\"" "'" "'"; }
:where(:lang(en-GB)) > * { quotes: "'" "'" "\"" "\""; }
:where(:lang(fr)) > * { quotes: "«\\00202F" "\\00202F»" "\"" "\""; }
q::before { content: open-quote; }
q::after { content: close-quote; }
The quotes property sets per-language pairs through :lang(), and the native q element emits the correct pair via open-quote and close-quote, so identical markup renders correctly in each locale without hardcoded characters. Wrapping the rules in :where() keeps specificity at zero, so any project can override the style with a single class.
Default sub and sup are synthesized—the browser shrinks the glyph and shifts the baseline rather than using characters drawn for the position.
@supports (font-variant-position: sub) {
:is(sub, .sub) {
vertical-align: baseline;
font-size: 100%;
line-height: inherit;
font-variant-position: sub;
}
}
@supports (font-variant-position: super) {
:is(sup, .sup) {
vertical-align: baseline;
font-size: 100%;
line-height: inherit;
font-variant-position: super;
}
}
font-variant-position uses the font's own sub/superscript glyphs where present, resetting vertical-align, font-size, and line-height so they don't fight the real glyph's intended size and placement. Most typefaces only supply proper numerals, not letters—check the specific font before applying it broadly.
Specificity: :where() for defaults, :is() for repetition
:where() always resolves to zero specificity, which is what a reset wants: every rule here is an opinionated default, and wrapping it lets a plain class override any property.
:where(h1, h2, h3, h4, h5, h6) {
margin-block: 0.5em;
}
:is() addresses repetition instead—the heading selector list recurs throughout a typographic stylesheet, and grouping it prevents a missed level.
:is(h1, h2, h3, h4, h5, h6), p, blockquote, figcaption, li {
text-box: trim-both cap alphabetic;
}
Unlike :where(), :is() takes the specificity of its most specific argument.
The complete stylesheet
The full reset combines the stable layers. Browsers discard unsupported declarations, so adoption can be gradual.
/* ==========================================================================
tidy-typography.css — a modern typography reset
Every rule degrades gracefully in unsupported browsers.
========================================================================== */
html {
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-synthesis: none;
-moz-text-size-adjust: none;
-webkit-text-size-adjust: none;
text-size-adjust: none;
}
body {
max-width: 800px;
margin: 0 auto;
padding: 1rem;
}
/* ---- Fluid typography ---- */
.article-container {
container-type: inline-size;
}
:root {
--step-0: clamp(1rem, 0.9rem + 1cqi, 1.125rem);
--step-1: clamp(1.25rem, 1.1rem + 1.5cqi, 1.5rem);
--step-2: clamp(1.6rem, 1.35rem + 2cqi, 2rem);
--step-3: clamp(2rem, 1.6rem + 3cqi, 2.75rem);
--step-4: clamp(2.5rem, 1.9rem + 4.5cqi, 4rem);
--vf-grad: 0;
}
@media (prefers-color-scheme: dark) {
:root {
--vf-grad: -50;
}
}
/* ---- Variable font fine-tuning ---- */
* {
font-variation-settings: "GRAD" var(--vf-grad, 0);
}
body {
font-size: var(--step-0);
font-size-adjust: from-font;
line-height: 1.6;
font-optical-sizing: auto;
font-variant-ligatures: common-ligatures contextual;
font-kerning: normal;
}
/* ---- Text box trim ---- */
:is(h1, h2, h3, h4, h5, h6), p, blockquote, figcaption, li {
text-box: trim-both cap alphabetic;
}
/* ---- Text wrap ---- */
:is(h1, h2, h3, h4, h5, h6), blockquote, figcaption {
text-wrap: balance;
font-size: var(--step-3);
line-height: 1.15;
letter-spacing: -0.01em;
}
h1 {
font-size: var(--step-4);
}
p, li, dd {
text-wrap: pretty;
max-width: 65ch;
hyphens: auto;
hyphenate-limit-chars: 6 3 3;
hyphenate-limit-lines: 2;
hyphenate-limit-zone: 8%;
hyphenate-limit-last: always;
}
pre, code, var, samp, kbd, :is(h1, h2, h3, h4, h5, h6) {
hyphens: manual;
}
blockquote, p {
hanging-punctuation: first allow-end last;
}
[contenteditable="true"] {
text-wrap: stable;
}
/* ---- Numeric, emoji, and script-aware text ---- */
table, .tabular {
font-variant-numeric: tabular-nums lining-nums;
}
.prose {
font-variant-numeric: oldstyle-nums proportional-nums;
}
.emoji-color {
font-variant-emoji: emoji;
}
.emoji-mono {
font-variant-emoji: text;
}
/* ---- Locale-aware quotes ---- */
:where(:lang(en)) > * {
quotes: '"' '"' "'" "'";
}
:where(:lang(en-GB)) > * {
quotes: "'" "'" '"' '"';
}
q::before {
content: open-quote;
}
q::after {
content: close-quote;
}
/* ---- Native sub and superscripts ---- */
@supports (font-variant-position: sub) {
sub, .sub {
vertical-align: baseline;
font-size: 100%;
line-height: inherit;
font-variant-position: sub;
}
}
@supports (font-variant-position: super) {
sup, .sup {
vertical-align: baseline;
font-size: 100%;
line-height: inherit;
font-variant-position: super;
}
}
/* ---- Ink-aware underlines ---- */
a {
text-decoration-thickness: from-font;
text-underline-offset: 0.15em;
text-decoration-skip-ink: auto;
}
Deciding what belongs in a reset
A large share of this CSS removes work that previously spilled into other parts of a build: text-wrap absorbs orphan handling once done in JavaScript, container query units keep a component's type scale tied to its own width, and text-box-trim replaces the negative margins once used to offset leading. The quotes, font-variant-position, and font-optical-sizing rules return smaller decisions to the language and the font rather than a pile of one-off fixes.
Support will keep shifting, particularly for text-wrap and text-box-trim. Ignoring unsupported declarations only helps when the unenhanced typography stands on its own.
Some rules remain too new for a baseline reset. A news article, a marketing page, and an editable product interface impose different demands on their text; which subset belongs in yours depends on the font, the content, and the browsers you must still support.



