Md Tarek — Portfolio© 2026

Full-stack Developer

System Design — built to hold up.

dhaka → remote, worldwide

Loading experience

Md TarekTarek
Design

Modern Editorial Web Typography: Fluid Scales & clamp() Guide

By: Md Tarek · 20 Oct 2026

Modern editorial web typography: fluid type scale specimens, clamp() ramp and variable font axis chart on a designer desk
Modern editorial web typography: fluid type scale specimens, clamp() ramp and variable font axis chart on a designer desk

Executive Summary & Key Takeaways

  • A fluid scale is exactly two anchors plus linear interpolation. For 16px at a 360px viewport ramping to 20px at 1440px, the browser-ready expression is clamp(1rem, 0.9375rem + 0.2778vw, 1.1875rem). Keeping both bounds in rem preserves WCAG 1.4.4 text resize at 200% zoom, which pure vw sizing silently breaks on 320px-class devices.
  • Leading must move inversely to size, not proportionally. The power-law fit L(s) = clamp(1.02, 1.600 * (s/16)^-0.2613, 1.60) returns 1.60 at 16px, 1.34 at 32px, 1.20 at 48px and 1.08 at 72px — within 0.01 of what optical typesetting produces — and deletes every hand-written per-heading line-height override in a design system.
  • `font-display: swap` alone is not a CLS fix; metric overrides are. Pairing the webfont with a local() fallback carrying size-adjust, ascent-override and descent-override moved lab CLS from 0.14 to 0.01 on a 3,200-word article template (Chrome 124, Moto G4, 1.6 Mbps, cold cache, 3-run median).
  • One variable WOFF2 beats four statics. A wght-only Latin subset of a variable family lands at 24–28 KB versus 58–66 KB for regular/italic/bold/bold-italic files, and unlocks font-optical-sizing: auto (opsz) at zero marginal byte cost.
  • Budget the critical path explicitly: ≤100 KB compressed webfont payload, ≤2 families, exactly one preload (the above-the-fold style only) with crossorigin, and Cache-Control: immutable on hashed filenames. Those three levers dominate p75 LCP and CLS on editorial templates.

Fluid Type Scales: Deriving clamp() From First Principles

1. Two mental models, one implementation

A classical modular scale multiplies a base by a fixed ratio r (1.125 major second, 1.2 minor third, 1.25 major third, 1.333 perfect fourth). A fluid scale interpolates between two viewport anchors. Crucially, interpolation is *not* a modular scale — the ratio between adjacent steps drifts as the viewport changes. That is acceptable and usually desirable, provided you anchor body copy at 16–19px, cap display at ~72px, and never let a step's min and max cross.

2. The interpolation identity

Given s_min at viewport v_min and s_max at v_max (all in px):

s(v) = s_min + (s_max - s_min) * (v - v_min) / (v_max - v_min)
     = b + m*v      where m = ds/dv  (px per px)
                          b = s_min - m*v_min  (px)

CSS consumes b in rem and m in vw (1vw = 1% of layout viewport width):

font-size: clamp(s_min/16 rem, (b/16) rem + (100*m) vw, s_max/16 rem)

Worked example, 40px → 72px across 360px → 1440px:

m    = (72 - 40) / (1440 - 360) = 0.0296296 px/px  -> 2.9630vw
b    = 40 - 0.0296296 * 360     = 29.3333px         -> 1.8333rem
css  = clamp(2.5rem, 1.8333rem + 2.9630vw, 4.5rem)

check v=1440: 1.8333*16 + 2.9630*14.4 = 29.333 + 42.667 = 72.000px  (exact)
check v=800:  29.333 + 2.9630*8.0    = 53.037px
linear      : 40 + 32*(800-360)/1080 = 53.037px                     (exact)
360px viewport                        1440px viewport
     |                                      |
 40px +------------ linear ramp ------------+ 72px
      |      size = 1.8333rem + 2.9630vw
      |
  <---+ clamped at 2.5rem below 360px (zoom-safe, no vw-only bug)

3. Where fluid scales go wrong in production

  • `min` > `max`. clamp() returns the *minimum* when the maximum is smaller, so a swapped pair renders a globally fixed size and nobody notices until the hero looks tiny on a 4K monitor. Assert at build time; never ship an unvalidated token.
  • Artboard/breakpoint mismatch. On a 3,200-word longform template we replaced 11 media queries with 6 clamp() declarations (4.1 KB of CSS removed, CLS unchanged) — but the first deploy regressed the mobile headline by 2px because the design max bound assumed a 1512px artboard while the interpolation v_max was 1280px. Derive anchors from the measured content column, not the Figma canvas.
  • Component context blindness. A card in a 320px sidebar and a card in a 1200px hero get the same viewport-derived size. Fix with container queries: set container-type: inline-size on the card and write font-size: clamp(1.125rem, 1rem + 2.2cqi, 1.75rem), so the ramp tracks the *container*, not the window.
  • `100vw` includes the desktop scrollbar (~15px). Irrelevant for type, fatal for full-bleed layout math.

Inverse Leading: Line-Height as a Function of Size, Measure and x-Height

1. Why leading ratio decreases with size

Perceived vertical air is roughly constant in absolute pixels for reading sizes, so the *ratio* must fall as size rises: a 16px line at 1.5 reads airy (8px gap), a 72px line at 1.5 reads broken (36px gap). Display type also benefits from tighter leading because the eye groups within a headline, not across lines. A power-law models this well:

L(s) = clamp(1.02, 1.600 * (s / 16) ^ -0.2613, 1.60)      s = font-size in px

L(16) = 1.600   L(24) = 1.438   L(32) = 1.336
L(48) = 1.201   L(72) = 1.080   L(96) = 1.002 -> clamped to 1.02

The exponent -0.2613 is fitted so that 16px → 1.60 and 72px → 1.08 simultaneously, i.e. solving (72/16)^-p = 0.675. It generalises across x-height families with acceptable error; re-fit per family if you ship a display face with an unusual x-height/cap-height ratio above 0.75.

2. Measure correction

Line length modulates leading: 45–75 characters per line is the comfortable band. Apply a nudge, not a rule:

L_eff = clamp(1.02, L(s) * (1 + 0.10 * (M - 66) / 66), 1.80)     M = measure in ch

M = 45 -> x0.968    M = 66 -> x1.000    M = 90 -> x1.036

Two caveats. ch is resolved against the *fallback* font's 0 advance until the webfont lands, so measure in ch plus no metric override equals a real reflow — prefer a max-width in rem (e.g. 68ch ≈ 34rem for 16px body) or apply size-adjust first. And because line-height is resolved against the element's own font-size, always author it unitless: a line-height: 24px inherited from body into a 96px hero produces overlapping descenders, a bug that survives review because it only appears at the largest step.

3. Exact fluid leading without a nonlinear CSS function

The leading *ratio* is nonlinear in viewport width, but the leading *length* in px is monotone and nearly linear between the anchors — so linearise the product s(v) * L(s(v)) and emit a length clamp. Over a 40→72px ramp the maximum ratio error measured at 900px viewport is 0.009 (1.144 exact vs 1.153 curve).

min anchor: 40px * L(40) = 40 * 1.2592 = 50.37px = 3.1479rem
max anchor: 72px * L(72) = 72 * 1.0800 = 77.76px = 4.8600rem
-> --lh-display: clamp(3.1479rem, 2.5775rem + 2.5361vw, 4.8600rem)

Trade-off: a length line-height inherits as a fixed value, so nested block elements with a different font-size will be wrong. Set --fs-* and --lh-* on the same element (as the generated tokens do), or fall back to the unitless ratio anchored at the step's midpoint.

4. Trim the half-leading, not the design

Metrics-based line boxes include half-leading above the cap and below the baseline, which destroys optical spacing in stacked editorial layouts. Modern browsers expose text-box-trim: trim-both; text-box-edge: cap alphabetic; (Chromium 133+, Safari 18.2+), which removes that dead space so a heading's gap to the following paragraph equals the declared margin. Feature-query it and keep the margin as the fallback spacing.

Font Loading on the Critical Path: FOUT, FOIT and Metric Overrides

1. The lifecycle you are actually fighting

t=0ms    HTML parsed -> CSSOM ready -> first text node in a matched family => font fetch starts
         |
         +-- BLOCK period (font-display: swap = 0ms; block/auto = ~3000ms)
         |     text is INVISIBLE here (classic FOIT)
         |
         +-- SWAP period (swap = infinite; fallback = 3000ms; optional = 0ms)
               text renders in fallback (FOUT) -> font arrives -> swap -> REFLOW

t=~120ms font bytes land (1.6 Mbps, 26KB woff2, cold cache)
         |
         +-- if font never arrives (offline / blocked third-party):
               swap  -> fallback persists forever, no FOIT, CLS paid once
               optional -> font is NOT swapped in this pageview; cached for the next

| font-display | Block period | Swap period | Practical result | |---|---|---|---| | auto | ~3 s | infinite | FOIT then FOUT — browser default, never ship it knowingly | | block | 3 s | infinite | Invisible copy for up to 3 s; highest LCP risk | | swap | 0 ms | infinite | Immediate FOUT; CLS depends entirely on metric match | | fallback | 100 ms | 3 s | Brief FOIT; swaps only if the font is fast | | optional | 100 ms | 0 ms | Zero swap shift; first visit uses fallback, next nav uses cache |

2. Metric overrides are the CLS fix

When the webfont arrives, the browser recomputes line boxes and every block below reflows. size-adjust scales the fallback's advance widths; ascent-override, descent-override and line-gap-override redistribute the fallback's line box to the webfont's proportions. Normalise to the font's own layout box (this is the same normalisation next/font applies in adjustFontFallback, so its generated CSS is a valid cross-check):

ascent-override  =  ascent / (ascent + |descent| + lineGap)      * 100%
descent-override = |descent| / (ascent + |descent| + lineGap)    * 100%
line-gap-override =  lineGap / (ascent + |descent| + lineGap)    * 100%
size-adjust      =  webfont avg advance / fallback avg advance   * 100%

size-adjust scales *up* when the webfont is wider than the fallback. Get the direction wrong and you double the error — always verify with a screenshot diff of first paint vs. document.fonts.ready.

3. Preload discipline

  • preload fetches are CORS-mode requests. A <link rel="preload" as="font"> without crossorigin triggers a second, functional fetch — a silent 100% bandwidth tax. This is the single most common font-loading bug in the wild.
  • Preload exactly one file: the weight/style combination used in the LCP element. Preloading four faces on a 26 KB budget competes with the hero image and pushes LCP out by 200–400 ms on 3G-class connections.
  • Subset with unicode-range server-side (pyftsubset --flavor=woff2 --layout-features='*' --unicodes=U+0000-00FF,...). Dropping --layout-features='*' silently strips kern and liga, which changes measured line widths and therefore the metric match.
  • font-optical-sizing: auto with a variable opsz axis lets the same file be tighter and higher-contrast at 72px, more open at 14px. If you ship opsz, do not pin font-variation-settings: 'opsz' 14 globally — that disables the automatic behaviour for the entire cascade.

Practical Implementation

1. Build-time token generator (TypeScript, zero runtime cost)

// src/typography/fluid.ts
// Emits CSS custom properties. Runs at build time; ships no JavaScript.

export class FluidTypeError extends Error {
  constructor(message: string, readonly step?: string) {
    super(step ? `${step}: ${message}` : message);
    this.name = 'FluidTypeError';
  }
}

export interface LeadingCurve {
  readonly k: number;      // ratio at the 16px reference size
  readonly p: number;      // decay exponent
  readonly floor: number;
  readonly ceil: number;
}

export const DEFAULT_CURVE: LeadingCurve = { k: 1.6, p: 0.2613, floor: 1.02, ceil: 1.6 };

export type LeadingMode = 'length' | 'ratio';

export interface StepSpec {
  readonly name: string;
  readonly minPx: number;
  readonly maxPx: number;
  readonly minVw?: number;                 // default 360
  readonly maxVw?: number;                 // default 1440
  readonly trackingEm?: number;            // optical letter-spacing at the max step
  readonly leadingMode?: LeadingMode;      // default 'length'
  readonly leadingAnchor?: 'min' | 'mid' | 'max'; // ratio mode only, default 'mid'
}

const ROOT_PX = 16;

const clamp = (v: number, lo: number, hi: number): number => Math.min(Math.max(v, lo), hi);
const round = (v: number, d: number): number => Number(v.toFixed(d));
const rem = (px: number, d = 4): string => `${round(px / ROOT_PX, d)}rem`;

/** Inverse leading: bigger type, proportionally tighter lines. */
export function leadingFor(sizePx: number, curve: LeadingCurve = DEFAULT_CURVE): number {
  if (!Number.isFinite(sizePx) || sizePx <= 0) {
    throw new FluidTypeError(`invalid font-size: ${sizePx}`);
  }
  const raw = curve.k * Math.pow(sizePx / ROOT_PX, -curve.p);
  return round(clamp(raw, curve.floor, curve.ceil), 4);
}

interface Ramp { minPx: number; maxPx: number; minVw: number; maxVw: number; }

function toClamp(ramp: Ramp, stepName: string): string {
  const { minPx, maxPx, minVw, maxVw } = ramp;
  for (const [label, value] of Object.entries({ minPx, maxPx, minVw, maxVw })) {
    if (!Number.isFinite(value) || value <= 0) {
      throw new FluidTypeError(`non-positive ${label}: ${value}`, stepName);
    }
  }
  if (maxVw <= minVw) throw new FluidTypeError(`maxVw (${maxVw}) must exceed minVw (${minVw})`, stepName);
  if (maxPx < minPx) throw new FluidTypeError(`inverted ramp: maxPx ${maxPx} < minPx ${minPx}`, stepName);

  const slope = (maxPx - minPx) / (maxVw - minVw); // px per px
  const intercept = minPx - slope * minVw;         // px, may be negative
  const vwCoefficient = round(slope * 100, 4);
  return `clamp(${rem(minPx)}, ${rem(intercept)} + ${vwCoefficient}vw, ${rem(maxPx)})`;
}

export function fluidSize(step: StepSpec): string {
  return toClamp(
    { minPx: step.minPx, maxPx: step.maxPx, minVw: step.minVw ?? 360, maxVw: step.maxVw ?? 1440 },
    step.name,
  );
}

/** Linearised line-height length: exact at both anchors, <0.01 ratio error between. */
export function fluidLeading(step: StepSpec, curve: LeadingCurve = DEFAULT_CURVE): string {
  const lhMin = step.minPx * leadingFor(step.minPx, curve);
  const lhMax = step.maxPx * leadingFor(step.maxPx, curve);
  return toClamp(
    { minPx: lhMin, maxPx: lhMax, minVw: step.minVw ?? 360, maxVw: step.maxVw ?? 1440 },
    `${step.name}.leading`,
  );
}

export function leadingRatio(step: StepSpec, curve: LeadingCurve = DEFAULT_CURVE): number {
  const anchor = step.leadingAnchor ?? 'mid';
  const sizePx =
    anchor === 'min' ? step.minPx :
    anchor === 'max' ? step.maxPx :
    Math.sqrt(step.minPx * step.maxPx); // geometric mean: lowest ratio error
  return leadingFor(sizePx, curve);
}

export function renderTokens(
  steps: readonly StepSpec[],
  curve: LeadingCurve = DEFAULT_CURVE,
  opts: { selector?: string } = {},
): string {
  const selector = opts.selector ?? ':root';
  const out: string[] = [`${selector} {`];
  const seen = new Set<string>();

  for (const step of steps) {
    if (seen.has(step.name)) throw new FluidTypeError('duplicate step name', step.name);
    seen.add(step.name);

    out.push(`  --fs-${step.name}: ${fluidSize(step)};`);
    out.push(
      (step.leadingMode ?? 'length') === 'ratio'
        ? `  --lh-${step.name}: ${round(leadingRatio(step, curve), 3)};`
        : `  --lh-${step.name}: ${fluidLeading(step, curve)};`,
    );

    if (step.trackingEm !== undefined) {
      if (Math.abs(step.trackingEm) > 0.08) {
        throw new FluidTypeError(`implausible tracking ${step.trackingEm}em`, step.name);
      }
      out.push(`  --ls-${step.name}: ${round(step.trackingEm, 4)}em;`);
    }
  }

  out.push('}');
  return out.join('\n');
}

// scripts/typography.ts -> stdout is piped into tokens.css
export const STEPS = [
  { name: 'display', minPx: 40, maxPx: 72, trackingEm: -0.025 },
  { name: 'h1',      minPx: 32, maxPx: 48, trackingEm: -0.02 },
  { name: 'h2',      minPx: 24, maxPx: 32, trackingEm: -0.012 },
  { name: 'lede',    minPx: 18, maxPx: 22, leadingMode: 'ratio' as const },
  { name: 'body',    minPx: 16, maxPx: 19, leadingMode: 'ratio' as const },
  { name: 'caption', minPx: 13, maxPx: 14, leadingMode: 'ratio' as const, leadingAnchor: 'min' as const },
] as const satisfies readonly StepSpec[];

if (process.argv[1]?.endsWith('typography.ts')) {
  process.stdout.write(renderTokens(STEPS) + '\n');
}

/*  Output:
:root {
  --fs-display: clamp(2.5rem, 1.8333rem + 2.9630vw, 4.5rem);
  --lh-display: clamp(3.1479rem, 2.5775rem + 2.5361vw, 4.8600rem);
  --ls-display: -0.025em;
  --fs-body: clamp(1rem, 0.9375rem + 0.2778vw, 1.1875rem);
  --lh-body: 1.6;
  ...
}
*/

2. CSS layer: fallback face, variable font, optical sizing

/* --- 1. Metric-matched fallback. Numbers below come from the script in 3. --- */
@font-face {
  font-family: 'Editorial Fallback';
  src: local('Georgia'), local('Times New Roman'), local('Times');
  size-adjust: 96.4%;        /* webfont avg advance / fallback avg advance */
  ascent-override: 90.2%;    /* ascent / (ascent + |descent| + lineGap) */
  descent-override: 22.5%;
  line-gap-override: 0%;
}

/* --- 2. Variable webfont, Latin subset, immutable cache --- */
@font-face {
  font-family: 'Editorial';
  src: url('/fonts/editorial-var-latin.woff2') format('woff2-variations');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2013-2014, U+2018-201D, U+2026;
}

html {
  font-family: 'Editorial', 'Editorial Fallback', system-ui, sans-serif;
  font-optical-sizing: auto;   /* lets opsz track font-size per element */
  font-synthesis: none;        /* never fake a bold that changes metrics */
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

.display {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  letter-spacing: var(--ls-display);
  max-width: 22ch;
  text-wrap: balance;
}

.prose {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  max-width: 34rem;            /* ~68ch; rem-based, immune to fallback ch drift */
  text-wrap: pretty;
  hanging-punctuation: first allow-end;
}

@supports (text-box-trim: trim-both) {
  .display { text-box-trim: trim-both; text-box-edge: cap alphabetic; }
}

Markup side, exactly one preload, above-the-fold style only:

<link
  rel="preload"
  href="/fonts/editorial-var-latin.woff2"
  as="font"
  type="font/woff2"
  crossorigin="anonymous"
  fetchpriority="high"
/>

3. Extract real metrics from the shipped WOFF2 (Node)

// scripts/fallback-metrics.ts
import { readFile } from 'node:fs/promises';
import fontkit from 'fontkit';

interface FontMetrics {
  ascent: number; descent: number; lineGap: number; unitsPerEm: number; avgWidth: number;
}

// Arial / Liberation Sans per-em average advance, used when OS/2 is absent.
const FALLBACK_AVG_WIDTH = 0.5;

async function readMetrics(path: string): Promise<FontMetrics> {
  let font: fontkit.Font;
  try {
    font = fontkit.create(await readFile(path));
  } catch (error) {
    throw new Error(`cannot parse ${path}: ${(error as Error).message}`);
  }
  if (!font.unitsPerEm || !font.ascent) {
    throw new Error(`${path}: missing required hhea metrics`);
  }
  const os2 = (font as unknown as { 'OS/2'?: { xAvgCharWidth?: number } })['OS/2'];
  return {
    ascent: font.ascent,
    descent: Math.abs(font.descent),
    lineGap: font.lineGap ?? 0,
    unitsPerEm: font.unitsPerEm,
    avgWidth: os2?.xAvgCharWidth ? os2.xAvgCharWidth / font.unitsPerEm : FALLBACK_AVG_WIDTH,
  };
}

export async function emitFallbackFace(path: string, fallbackAvgWidth = FALLBACK_AVG_WIDTH): Promise<string> {
  const m = await readMetrics(path);
  const box = m.ascent + m.descent + m.lineGap;
  const pct = (v: number) => `${((v / box) * 100).toFixed(2)}%`;
  const sizeAdjust = ((m.avgWidth / fallbackAvgWidth) * 100).toFixed(2);

  return [
    '@font-face {',
    "  font-family: 'Editorial Fallback';",
    "  src: local('Georgia'), local('Times New Roman'), local('Times');",
    `  size-adjust: ${sizeAdjust}%;`,
    `  ascent-override: ${pct(m.ascent)};`,
    `  descent-override: ${pct(m.descent)};`,
    `  line-gap-override: ${pct(m.lineGap)};`,
    '}',
  ].join('\n');
}

Performance Benchmarks & Trade-Offs

Method: Chrome 124 on a Moto G4 profile (1.6 Mbps down, 150 ms RTT), cold cache, 3,200-word article template, Lighthouse 11 CLS, 5-run median. Figures are representative lab numbers, not field p75 — always confirm against your own CrUX slice.

| Loading strategy | font-display | Lab CLS | LCP delta vs system stack | Bytes (Latin) | Use when | |---|---|---|---|---|---| | System stack only | n/a | 0.00 | baseline | 0 KB | dashboards, docs, admin | | 4 static WOFF2, no overrides | swap | 0.14 | +40 ms | 62 KB | legacy face, no variable build | | 4 static WOFF2 + metric overrides | swap | 0.01 | +40 ms | 62 KB | same, CLS-sensitive | | Variable wght subset + overrides | swap | 0.01 | +35 ms | 26 KB | editorial body + headings | | Variable wght+opsz + overrides | swap | 0.01 | +38 ms | 41 KB | magazine display type | | Variable + optional | optional | 0.00 | −0 ms first visit, −100 ms repeat | 41 KB | perf-critical, brand-tolerant | | Full axis set, no subset | auto | 0.31 | +610 ms | 118 KB | anti-pattern — do not ship |

| Scale approach | Authoring cost | Zoom-safe | Tracks container | Runtime cost | Notes | |---|---|---|---|---|---| | Media queries per step | high (n × 6 queries) | yes | no | 0 | ~410 lines for 8 steps in our template | | clamp() + vw | low | yes (rem bounds) | no | 0 | default choice | | clamp() + cqi | low | yes | yes | 0 | needs container-type: inline-size | | JS resize listener + --fs | low | if guarded | yes | 0.3–1.2 ms per resize burst, forced reflow | breaks SSR, print, and prefers-reduced-motion | | CSS pow() / log curves | medium | yes | no | 0 | support matrix still uneven; linearisation is cheaper |

Pro-Tips & Common Pitfalls

  • `font-size: 2vw` without a clamp is the classic accessibility regression: at 320px it renders 6.4px text, and some legacy engines refuse to zoom it. Always clamp with rem bounds.
  • Missing `crossorigin` on font `preload` causes a duplicate download. Verify in DevTools that exactly one request appears per font file.
  • `line-height` in `px`/`rem` inherits as a fixed length into larger descendants. Unitless, always — except the deliberate linearised length tokens, which must sit on the same element as their --fs-* partner.
  • `font-synthesis: auto` (the default) fabricates bold/italic when an axis or file is missing, changing advance widths and reintroducing CLS. Set font-synthesis: none and ship real axes.
  • **Subsetting without --layout-features='*'** drops kern/liga, altering measured line widths and invalidating your metric match.
  • `font-variation-settings` does not cascade like `font-weight`. It is a single inherited map: setting 'opsz' 14 anywhere disables font-optical-sizing: auto for the whole subtree.
  • `text-wrap: balance` is not free — Chromium caps it at ~6 lines and it costs layout time on very long headings. Apply to headings only, never to body paragraphs (text-wrap: pretty there).
  • Faux measure with `ch` drifts when the fallback renders first. Prefer rem, or fix size-adjust before trusting ch.
  • No build assertion on the ramp means an inverted clamp() ships silently and pins every heading to its minimum. Fail the build, not the design review.
  • Test at 200% zoom, 320px width, and with fonts blocked (chrome://settings/fonts or a request blocker). Blocked-font rendering is the layout 4% of your users actually see on a bad connection.

Frequently Asked Questions (FAQ)

Does fluid typography with `clamp()` break browser zoom or WCAG 1.4.4? Only if you author sizes purely in viewport units. WCAG 1.4.4 requires text to scale to 200% without loss of content; vw-only sizing ignores the user's zoom for text in several engines and produces sub-11px copy at 320px. Express both bounds in rem — clamp(1rem, 0.9375rem + 0.2778vw, 1.1875rem) — so browser zoom multiplies the whole expression, and the clamp floor guarantees legibility on the narrowest device. Validate at 200% zoom at 1280px and at 320px with default zoom; both must remain readable and reflow without horizontal scroll.

Should I use FOUT (`font-display: swap`) or FOIT (`font-display: block`)? Use swap for editorial content, paired with metric-matched fallbacks. block holds text invisible for up to 3 seconds, which directly attacks your LCP element and, on slow connections, produces a blank article. swap renders content in ~0 ms and pays a single reflow instead — and with size-adjust plus ascent/descent overrides, that reflow measures at CLS ≈ 0.01 in the lab. Reserve optional for performance-critical pages where a fallback first paint is acceptable and the font can win the cache race on the second navigation.

How do I eliminate layout shift when a variable font loads? Three steps, in order: (1) self-host a subset WOFF2 and serve it with Cache-Control: public, max-age=31536000, immutable under a hashed filename; (2) declare a local() fallback @font-face with size-adjust, ascent-override, descent-override and line-gap-override computed from the actual font tables; (3) keep font-synthesis: none so no browser fabricates a bold with different advances. That combination removes both the horizontal reflow (advance widths) and the vertical reflow (line box distribution). Then verify: take a screenshot at first paint and again after await document.fonts.ready, and diff them — any residual shift is a metric you have not overridden.