Chapter 21: Typography on screens
On paper, a letter’s shape is fixed when the plate is made. On a screen it’s rebuilt every time the text appears: software scales an outline to a grid of pixels, sometimes in a font still downloading, at a size the device and the reader choose. Screen typography is the work of keeping text readable through all of that.
Rendering and hinting
Rendering is turning a glyph’s outline into pixels. At 16 px, a stem might be 1.4 pixels wide, and the software has to decide what to do with the fraction. Whole pixels switched on or off give jagged letters. Anti-aliasing shades the edge pixels in proportion to how much of each the outline covers, which smooths the edges but softens them. Subpixel rendering goes further on LCD screens, where each pixel is three vertical stripes of red, green and blue. Microsoft’s ClearType draws to the stripes separately, which in theory triples horizontal resolution.1
Hinting is a set of instructions stored in the font that adjust its outlines at small sizes so they land cleanly on the pixel grid, a step Microsoft calls grid-fitting.2 Good hinting keeps stems even and x-heights aligned, and keeps a bold visibly bolder than the regular at 9 pt. Verdana, which Microsoft released on 8 July 1996, was designed by Matthew Carter for the screen and hand-hinted by Tom Rickner. Its wide letters and loose spacing keep “rn” from merging into “m” when pixels are scarce.3
Hinting matters far less than it did. A high-density screen has enough pixels to draw the outline close to its design, and macOS largely ignores the hints in a font and applies its own.4 Apple also turned subpixel anti-aliasing off by default in macOS Mojave in 2018.5 Windows still uses hints and ClearType, and many office monitors are low density, so check small interface text on one (→ 35 Resolution, formats and units).
Web fonts, FOUT and FOIT
A web font is a font file the browser downloads with the page, declared in CSS with an @font-face rule, instead of one already installed on the reader’s device. The usual format is WOFF2, a W3C standard that compresses font data with the Brotli algorithm.6 The HTTP Archive’s 2024 Web Almanac found web fonts on about 87% of websites, and WOFF2 on 81% of desktop sites.7
The cost is a wait. The CSS Fonts specification splits it into three periods.8 In the block period, text is drawn with an invisible fallback: its space is held but nothing shows. In the swap period, a fallback shows until the web font arrives and replaces it. In the failure period, the browser gives up and keeps the fallback. The font-display descriptor sets these periods for each font, with durations the specification recommends:
font-display | Block period | Swap period | Suits |
|---|---|---|---|
block | short (3 s) | unlimited | small text that’s useless in another font |
swap | 100 ms or less | unlimited | headings, a name set in type |
fallback | 100 ms or less | short (3 s) | body text |
optional | 100 ms or less | none | text where the font is a bonus |
The specification suggests fallback for body text, so a paragraph doesn’t reflow mid-read.8 In practice swap is the most common value, on 44% of desktop pages.7 To make a swap less jarring, pick a fallback with a similar x-height and width, and fine-tune it with the size-adjust descriptor.9
font-display value divides it.Type scales
A type scale is the fixed set of sizes an interface uses for its levels of hierarchy (→ 19 Setting text). Bringhurst traces the traditional scale to European printers of the 16th century and advises “a modest set of distinct and related intervals”, taken from it or devised fresh.11 In 2011 Tim Brown proposed the modular scale for the web: sizes made by multiplying a base by a fixed ratio again and again.12 With a 16 px base and a ratio of 1.25, the steps are 16, 20, 25, 31 and 39 px.
A ratio is a starting point. Apple’s iOS text styles at the default setting are 11, 12, 13, 15, 16, 17, 20, 22, 28 and 34 pt, with body text at 17 pt, and no single ratio produces them.13 Apple also sets minimums: 11 pt on iOS and iPadOS, 10 pt on macOS. Those styles grow and shrink with Dynamic Type, the setting that lets iPhone users choose their text size. So define an app’s scale as named roles, such as body, caption and title, not as a list of numbers, and store them as tokens (→ 65 Design systems).
Fluid and responsive type
Responsive type changes size in steps at breakpoints set with media queries (→ 67 Responsive, mobile-first and cross-device design). Fluid type changes size continuously with the viewport width, between a minimum and a maximum. Mike Riethmuller published a technique in 2015: a CSS calc() expression that adds a share of the viewport width to a base size, so text grows from 12 px at a 400 px viewport to 24 px at 800 px.14 clamp() now does it in one line, with a lower bound, a preferred value and an upper bound: font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem).15
Utopia, which James Gilyead and Trys Mudford published in 2020, applies the idea to a whole type scale. The designer sets one scale for a small screen and one for a large screen, say a ratio of 1.2 at 320 px and 1.333 at 1,500 px, and the browser interpolates every step between them.16 Headings grow faster than body text, which is usually what a hierarchy needs.
The trap is the viewport unit. Text sized only in vw doesn’t grow when the reader zooms, which fails WCAG Success Criterion 1.4.4, Resize text (level AA); the W3C lists it as failure F94.17 Keep a rem term in the preferred value and set the bounds in rem too. MDN advises a maximum at least twice the minimum, so text can still reach 200%15 (→ 74 HTML and CSS).
Variable fonts in use
A variable font is a single font file that holds a continuous range of styles along one or more axes, such as weight or width, in place of one file per style (→ 18 A history of type). By 2024 about a third of web pages used one.7
The specification defines five registered axes, and CSS maps each to an ordinary property: weight (wght) to font-weight, width (wdth) to font-stretch, italic (ital) and slant (slnt) to font-style, and optical size (opsz) to font-optical-sizing. MDN advises using those properties and keeping the low-level font-variation-settings for custom axes.18 Optical size is on by default: where a font has the axis, the browser draws small text sturdier and large text finer.19
In practice a variable font allows a body weight of 450 where 400 looks thin on a dark background, or a slightly narrower headline that fits a phone screen. It isn’t always lighter. The file is bigger than any single static font, though usually no bigger than the four that body text needs (regular, italic, bold and bold italic).18 If a page uses one weight, a static file wins.
Anek, from Ek Type, a collective of type designers in Mumbai, is a variable family covering nine Indian scripts plus Latin on weight and width axes, under the SIL Open Font License2021 (→ 22 Type across scripts).
See also
- 18 A history of type
- 19 Setting text
- 20 Choosing, pairing and legibility
- 35 Resolution, formats and units
- 67 Responsive, mobile-first and cross-device design
- 74 HTML and CSS
Sources
- Apple. Human Interface Guidelines, “Typography.” Apple Developer.
- Bringhurst, R. (2004). The Elements of Typographic Style, 3rd ed. Hartley & Marks. Quoted via Rutter, R. The Elements of Typographic Style Applied to the Web.
- Brown, T. (2011). “More meaningful typography.” A List Apart, May 3.
- Ek Type. Anek (source repository). GitHub.
- Gilyead, J. (2020). “Designing with fluid type scales.” Utopia, February 1.
- Glyphs. “Hinting: TrueType autohinting.” Glyphs tutorial.
- Google Design. “Anek: a multiscript variable font family.”
- Irish, P. (2009). “Fighting the @font-face FOUT.” October 7.
- MDN Web Docs.
clamp(),size-adjust,font-optical-sizing, “Variable fonts guide.” Mozilla. - Microsoft Typography. “TrueType hinting”; “Microsoft ClearType”; “Verdana font family.” Microsoft Learn.
- Riethmuller, M. (2015). “Precise control over responsive typography.” March 17.
- Stein, B., and Berret, C. (2024). “Fonts.” Web Almanac 2024, chapter 4. HTTP Archive.
- W3C. CSS Fonts Module Level 4, §3.2 and §4.9.
- W3C (2024). WOFF File Format 2.0. W3C Recommendation.
- W3C. Understanding WCAG 2.2, SC 1.4.4; Technique F94.
- WebKit. Changeset 239306 (Fraser, S., 2018).
Notes
- Microsoft Typography, “Microsoft ClearType.” https://learn.microsoft.com/en-us/typography/cleartype/ ↩
- Microsoft Typography, “TrueType hinting.” https://learn.microsoft.com/en-us/typography/truetype/hinting ↩
- Microsoft Typography, “Verdana font family.” https://learn.microsoft.com/en-us/typography/font-list/verdana ↩
- Glyphs, “Hinting: TrueType autohinting.” https://glyphsapp.com/learn/hinting-truetype-autohinting ↩
- WebKit changeset 239306, December 17, 2018. https://trac.webkit.org/r239306 ↩
- W3C (2024), WOFF File Format 2.0. https://www.w3.org/TR/WOFF2/ ↩
- Stein and Berret (2024), Web Almanac, “Fonts.” https://almanac.httparchive.org/en/2024/fonts ↩ ↩ ↩
- W3C, CSS Fonts Module Level 4, §3.2 “The font display timeline” and §4.9 “font-display.” https://www.w3.org/TR/css-fonts-4/ ↩ ↩
- MDN Web Docs, “size-adjust.” https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/size-adjust ↩
- Irish, P. (2009). https://paulirish.com/2009/fighting-the-font-face-fout/ ↩
- Bringhurst (2004), §3.1.1, quoted in Rutter, http://webtypography.net/3.1.1 ↩
- Brown, T. (2011). https://alistapart.com/article/more-meaningful-typography/ ↩
- Apple, Human Interface Guidelines, “Typography.” https://developer.apple.com/design/human-interface-guidelines/typography ↩
- Riethmuller, M. (2015). https://www.madebymike.com.au/writing/precise-control-responsive-typography ↩
- MDN Web Docs, “clamp().” https://developer.mozilla.org/en-US/docs/Web/CSS/clamp ↩ ↩
- Gilyead, J. (2020). https://utopia.fyi/blog/designing-with-fluid-type-scales/ ↩
- W3C, Understanding SC 1.4.4, https://www.w3.org/WAI/WCAG22/Understanding/resize-text.html; Technique F94, https://www.w3.org/WAI/WCAG22/Techniques/failures/F94 ↩
- MDN Web Docs, “Variable fonts guide.” https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide ↩ ↩
- MDN Web Docs, “font-optical-sizing.” https://developer.mozilla.org/en-US/docs/Web/CSS/font-optical-sizing ↩
- Ek Type, Anek. https://github.com/EkType/Anek ↩
- Google Design, “Anek multiscript.” https://design.google/library/anek-multiscript ↩