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.
| Value | Block period | Swap behavior | Best suited for |
|---|---|---|---|
auto | Browser default, often about 3 s | Browser decides | Rarely a deliberate choice |
block | Up to about 3 s | Swaps whenever the font arrives | Icon fonts and logotypes |
swap | Extremely short | Always swaps when loaded | Brand headings and body text |
fallback | About 100 ms | Swaps only within about 3 s | Body text on slower networks |
optional | About 100 ms | Browser may skip the font | Performance-critical pages |
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.
| Format | Compression | Browser support today | Recommended use |
|---|---|---|---|
| WOFF2 | Brotli, strongest | All current browsers | Default choice for every project |
| WOFF | zlib, moderate | Universal, including legacy browsers | Fallback only for very old clients |
| TTF and OTF | None | Broad but inefficient | Desktop use, not web delivery |
| EOT | Optional | Legacy Internet Explorer only | Obsolete, avoid |
| SVG fonts | None | Removed from most browsers | Obsolete, avoid |
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.
| Criterion | Self-hosted | Font delivery service |
|---|---|---|
| Performance | No extra connection to another origin | Requires DNS lookup and new connection |
| Privacy | No visitor data sent to third parties | Visitor IP addresses reach the provider |
| Control | Full control over subsetting and caching | Limited control over files and headers |
| Maintenance | Team updates files manually | Provider updates fonts automatically |
| Licensing | Must verify self-hosting rights | License often bundled with service |
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-overrideanddescent-overridetune 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 type | Recommended approach | Reason |
|---|---|---|
| Content site or blog | One or two subsetted WOFF2 files with swap | Fast reading matters more than exact styling |
| Brand marketing site | Preloaded heading font plus tuned fallback | Identity is visible without layout jumps |
| Web application | System font stack or one variable font | Interface speed and consistency |
| Multilingual site | Subsets split with unicode-range | Users download only the scripts they need |
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.
| Problem | Cause | Fix |
|---|---|---|
| Invisible text on load | Long block period on slow networks | Use swap or fallback in font-display |
| Layout jumps after swap | Fallback metrics differ from web font | Apply size-adjust and metric overrides |
| Slow first render | Too many weights and styles loaded | Limit families and use a variable font |
| Faux bold or italic | Missing style file, browser synthesizes it | Load the real style or disable synthesis |
| Missing characters | Over-aggressive subsetting | Include all scripts the content uses |
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.