Web font

On this page 7

A web font is a font file downloaded by the browser together with a web page and used to render its text, instead of relying only on fonts already installed on the visitor’s device. In typography for digital products, web fonts make it possible to apply a brand typeface consistently across operating systems, browsers and screens.

Web fonts are declared in CSS with the `@font-face` rule, which names a font family and points to one or more font files. The browser fetches those files, often from the same server or from a font delivery service, and swaps them into the layout once they arrive. This flexibility comes with a cost: every web font adds download weight, rendering delay and licensing obligations that designers and developers must manage.

How browsers load and render a web font

Loading a web font is a multi-step process controlled by the browser. The browser parses the HTML and CSS, builds the render tree and only requests a font file when it discovers text that actually uses that font family. This lazy behavior saves bandwidth but means the font request often starts late, after the CSS has already been downloaded and processed.

While the font is in transit, the browser must decide what to show. It may hide the text for a short block period, display a fallback font and swap later, or give up on the web font entirely for that page view. These choices produce two well-known symptoms: the flash of invisible text (FOIT) and the flash of unstyled text (FOUT).

The `font-display` descriptor inside @font-face lets authors choose the strategy explicitly. The table compares its values and their typical effects.

ValueBlock periodSwap behaviorBest suited for
autoBrowser default, often about 3 sBrowser decidesRarely a deliberate choice
blockUp to about 3 sSwaps whenever the font arrivesIcon fonts and logotypes
swapExtremely shortAlways swaps when loadedBrand headings and body text
fallbackAbout 100 msSwaps only within about 3 sBody text on slower networks
optionalAbout 100 msBrowser may skip the fontPerformance-critical pages
Values of the font-display descriptor

Web font file formats

Web fonts have passed through several file formats, but modern practice has converged on WOFF2 as the standard format. WOFF2, defined by the W3C, wraps TrueType or OpenType outlines in a container compressed with the Brotli algorithm, typically making files about 30 percent smaller than WOFF and much smaller than raw TTF or OTF files.

FormatCompressionBrowser support todayRecommended use
WOFF2Brotli, strongestAll current browsersDefault choice for every project
WOFFzlib, moderateUniversal, including legacy browsersFallback only for very old clients
TTF and OTFNoneBroad but inefficientDesktop use, not web delivery
EOTOptionalLegacy Internet Explorer onlyObsolete, avoid
SVG fontsNoneRemoved from most browsersObsolete, avoid
Common web font formats

A single typeface family often requires several files, one per weight and style. A family with regular, italic, bold and bold italic needs four requests unless the project uses a variable font, which stores a continuous range of weights or widths in one file. Variable fonts can reduce the number of requests, although one variable file is usually larger than any single static weight.

Self-hosting compared with font delivery services

Teams can either self-host web fonts on their own server or content delivery network, or load them from a third-party font service. The choice affects performance, privacy, control and licensing. Since modern browsers partition their HTTP cache by site, a font downloaded on one website is no longer reused on another, which removed the main historical advantage of shared font services.

CriterionSelf-hostedFont delivery service
PerformanceNo extra connection to another originRequires DNS lookup and new connection
PrivacyNo visitor data sent to third partiesVisitor IP addresses reach the provider
ControlFull control over subsetting and cachingLimited control over files and headers
MaintenanceTeam updates files manuallyProvider updates fonts automatically
LicensingMust verify self-hosting rightsLicense often bundled with service
Self-hosted fonts compared with hosted font services

Privacy considerations are not theoretical. In the European Union, courts have treated the transfer of visitor IP addresses to a font service without a legal basis as a data protection issue under the GDPR, which has pushed many organizations toward self-hosting by default.

Optimizing web font performance

Web fonts frequently delay the Largest Contentful Paint and cause Cumulative Layout Shift when a fallback is replaced by a font with different metrics. Good optimization reduces bytes, starts the download early and keeps the swap visually stable.

  • Subsetting removes unused glyphs, for example by keeping only Latin characters, and can shrink a file by more than half.
  • The `unicode-range` descriptor lets the browser download a subset only when the page contains characters from that range.
  • A preload hint for the most important font file starts the request early, but preloading too many files competes with other critical resources.
  • Metric overrides such as size-adjust, ascent-override and descent-override tune the fallback font to match the web font and minimize layout shift.
  • Long-lived cache headers with versioned file names ensure repeat visits do not download fonts again.

The decision table below summarizes practical choices for common project types.

Project typeRecommended approachReason
Content site or blogOne or two subsetted WOFF2 files with swapFast reading matters more than exact styling
Brand marketing sitePreloaded heading font plus tuned fallbackIdentity is visible without layout jumps
Web applicationSystem font stack or one variable fontInterface speed and consistency
Multilingual siteSubsets split with unicode-rangeUsers download only the scripts they need
Web font strategy by project type

Licensing, accessibility and common mistakes

A font is licensed software, and desktop licenses rarely cover web embedding. Commercial foundries usually sell separate web licenses priced by page views or domains, while open fonts under the SIL Open Font License may be self-hosted and modified freely within its terms. Teams should confirm the license before converting or subsetting any font file.

Accessibility depends on how the font is chosen and used. Text rendered with a web font remains real, selectable and searchable text, unlike text embedded in images, but a decorative typeface with low x-height or tight spacing can reduce legibility. Designers should test sizes, weights and contrast on real devices.

ProblemCauseFix
Invisible text on loadLong block period on slow networksUse swap or fallback in font-display
Layout jumps after swapFallback metrics differ from web fontApply size-adjust and metric overrides
Slow first renderToo many weights and styles loadedLimit families and use a variable font
Faux bold or italicMissing style file, browser synthesizes itLoad the real style or disable synthesis
Missing charactersOver-aggressive subsettingInclude all scripts the content uses
Frequent web font problems

The short version

Normally, a computer can only show text in the fonts it already has. A web font solves this by sending the font along with the website, much like a guest bringing their own dishes to a dinner so the meal looks exactly as planned.

The catch is that the font has to arrive before it can be used. If it is large or slow, the visitor may briefly see blank or plain text. Good design keeps web fonts small, few and quick to load, so the page looks right without making anyone wait.

Where it makes a difference

An online magazine uses a serif typeface for articles and a sans-serif for headings, loaded in six static weights from a third-party service. On mobile networks, readers often see blank text for up to three seconds, and the page jumps when the fonts finally appear.

The front-end team switches to self-hosted WOFF2 files, replaces the six heading weights with one variable font and subsets both families to Latin characters. Total font weight falls from roughly 420 KB to about 110 KB. They preload only the body font, set font-display to swap and tune the fallback with size-adjust so line lengths barely change during the swap.

After deployment, text appears immediately in a closely matched fallback, the visible layout shift disappears and the Largest Contentful Paint on mid-range phones improves noticeably. The magazine keeps its distinctive look while giving readers faster, steadier pages and removing a third-party data transfer.