What WCAG actually mandates

The Web Content Accessibility Guidelines do not set a minimum font size for the web. Instead, they regulate two things: users must be able to resize text by 200% without loss of readability, collisions, or overlapping content, and text must clear a contrast ratio of at least 4.5:1 — relaxed to 3:1 for large-scale text. WebAIM's Contrast Checker is one way to verify the latter.

A contrast ratio of 2.39 to 1 would not pass any of the WCAG checks, a ratio of 4.65 to 1 would pass only the AA check for normal text sizes and a 10.09 to 1 contrast ratio would pass both AA and AAA WCAG checks.
Example of three color contrast measurements and their WCAG test results according to WebAIM’s contrast checker.

Size stays out of the spec because the world has roughly 300 alphabets. Characters that read cleanly small and characters dense enough to lose vital detail at the same size can't share a single numeric threshold. The spec also defines "large text" loosely as the minimum large print size used for a language and the next larger standard size; for Roman text under AAA, that's 18 points, which equals 24px on some displays since sizes are measured in points rather than pixels. CJK or Arabic text works out differently in pixels:

Hello สวัสดี مرحبا 你好

In short, WCAG specifies contrast, not size.

The WCAG recommended font size for large text has greater contrast than something half the size. Notice how a larger font size lets in more of the background that sits behind the text.

Build on the browser's defaults

Browser default styles are accessible, so the practical strategy is to leverage them. The user agent stylesheet loads first, cascades into author styles, and both are overwritten by the user's own styles. That matters because a meaningful share of users change their default font size in browser settings — Adrian Sandu cites an Internet Archive study to this effect in his article on rem units.

font-family is equally out of our hands: content may be translated, a custom font may fail to load or be swapped (OpenDyslexic, for dyslexic readers, is one case), and some interfaces deliberately allow switching between a limited set of fonts. We don't know where our content will land, so the only reliable thing we control is proportions.

Relative units and no base size

CSS relative units tie content to whatever the environment reports, and WCAG recommends em units for font size. Rems and ems work for everything, not just font sizes — borders are the usual exception, kept in pixels. My advice is to skip font-size on :root, <html> and <body> entirely and let the browser default serve as the baseline. The WCAG 2.2 working draft supports this: without a specified size, the smallest size major browsers use for unspecified text is a reasonable assumption.

Exceptions exist. Intricate, thin, or very short x-height fonts may warrant bumping the base up to reach correct contrast — the spec notes that thin strokes or unusual letterforms reduce familiarity and are harder to read at lower contrast. Users may also adjust the base themselves: larger for low vision, smaller for more screen real estate.

:root {
  /* Do not set a font-size on a :root, body nor html level */
  /* Let your main text size be decided by the browser or the user settings */ 
}
.small {
  font-size: .8rem;
}
.large {
  font-size: 2rem;
}

Headings

Heading elements create the document outline screen readers navigate, and heading order is itself a WCAG criterion: descending order, no skipped levels, so an h4 follows an h3. Resetting all heading sizes to 1rem is a useful strategy for forcing visual treatment apart from meaning.

Keeping a pixel mindset in relative units

rem computes against the <html> element; em against its own element. Since major browsers default to 16px, a pixel-based typographic hierarchy can be set at 16px for body text and calculated proportionately in rem for everything else.

Browser NameBase Font Size
Chrome v80.016px
FireFox v74.016px
Safari v13.0.416px
Edge v80.0 (Chromium based)16px
Android (Samsung, Chrome, Firefox)16px
Safari iOS16px
Kindle Touch26px (renders as 16px since it’s a high density screen)

Three conversion methods:

  1. The 62.5% rule. Set root sizing to 62.5%, making 1rem equal 10px and pixel-to-rem conversion trivial.
  2. calc(). Divide the pixel value by the assumed browser font base in CSS directly.
  3. A pixel-to-rem function. Preprocessor implementations exist in many flavors, including a Sass mixin and styled-components' polish — and the same function can be built in vanilla CSS.
:root {
  font-size: 62.5%; /* (62.5/100) * 16px = 10px */
  --font-size--small: 1.4rem; /* 14px */
  --font-size--default: 1.6rem; /* 16px */
  --font-size--large: 2.4rem; /* 24px */
}


.font-size--small {
  font-size: var(--font-size--small);
}

.font-size--default {
  font-size: var(--font-size--default);
}

.font-size--large {
  font-size: var(--font-size--large);
}
:root {
  --font-size--small: calc((14/16) * 1rem); /* 14px */
  --font-size--default: calc((16/16) * 1rem); /* 16px */
  --font-size--large: calc((24/16) * 1rem); /* 24px */
}


.font-size--small {
  font-size: var(--font-size--small);
}

.font-size--default {
  font-size: var(--font-size--default);
}

.font-size--large {
  font-size: var(--font-size--large);
}
:root {
  --font-size--small: prem(14); /* 14px */
  --font-size--default: prem(16); /* 16px */
  --font-size--large: prem(24); /* 24px */
}


.font-size--small {
  font-size: var(--font-size--small);
}

.font-size--default {
  font-size: var(--font-size--default);
}

.font-size--large {
  font-size: var(--font-size--large);
}

Is it possible to create a "Pixel to rem" function without using a preprocessor? Yes!

✨See it in action!https://t.co/kPfIMxO0vw

cc/ @srambach @matthewcarleton #CSS #DontDoIt pic.twitter.com/PKxE7QCWuO

— Andrés Galante (@andresgalante) March 3, 2020

Guidelines to keep

We don't control how content is consumed — browser settings, zoom levels, and other customizations all intervene. These practices keep a good experience alongside those preferences:

  • Work with proportions instead of explicit sizes.
  • Rely on default browser font sizes instead of setting it on the :root, <html> or <body>.
  • Use rem units to help scale content with a user's personal preferences.
  • Avoid making assumptions and let the environment decide how your content is being consumed.