Getting Started with Font Stacks
A font stack is the instruction in a page of CSS code that tells a browser what fonts to display, and what to do should the first choice font be unavailable or not working.
Designers can specify any font they wish in their CSS, but if the visitor’s browser can’t find that font file then it will choose a system font on the basis of its default settings. To almost any typographically-inclined designer, that degree of randomness in the outcome will cause many sleepless nights.
To combat that randomness, a font stack will tell the browser how it should behave if the designer’s specified font isn’t available, working through a list of fallback options that get progressively broader in definition.
Font stacks are included as part of the “font-family” CSS declaration. Here’s what a typical font stack might look like in a chunk of code defining the basic body text for a website:
font-family: “Supria Sans”, Helvetica, Arial, sans-serif;
In first position is the designer’s preferred font, in this case a contemporary interpretation of a famous Swiss typeface. Next is an acceptable alternative, followed by a more widely available but not so well loved font. The last reference is a generic description that the browser understands and can use to pick a system font that will be from the same general category as the first choice font.
Building a font stack is one area of web design where typophiles can really bring their existing knowledge into play. Consider the fallbacks’ line length, x-height and contrast as well as its classification, style and weight. Match your fallbacks as best as you can, but be prepared for those progressively broader compromises.
Remember to take your readership into account: different types of internet users will have different types of operating system. The fonts that have shipped with operating systems have changed over the years, so a tech-savvy audience will be better equipped with the latest system fonts than certain types of casual home user. A search for “XP system fonts list” returns several good resources, including Microsoft’s own site and a Wikipedia page. Software packages (MS Office and Adobe CS Suite are the most obvious examples) also often ship with font libraries, so with some careful research and target user group identification, your fallback fonts needn’t be limited to the most widely available options.
Best practice for font stacks:
- Always choose fonts that render well on screen at the intended sizes.
- Consider the fallbacks’ line length, x-height and contrast as well as its classification, style and weight.
- Choose your fallbacks to match your visitors’ likely technical capability and/or operating system.
Font stacks are a powerful tool that can do more than just manage the way a browser knows which font to display. In future articles, we'll talk further about how to match typographic choices to types of user, and how to manipulate our fallbacks to create some interesting typesetting effects and tricks.Back...
Posted 31 Mar, 2011 by anthony-noel
Filter articles by category:
Filter articles By tag:
- Autotranslate (1)
- CSS (3)
- Drop caps (1)
- Fashion (1)
- Font stacks (1)
- grunge effect (1)
- hand drawn (1)
- Hosting (1)
- Illustrative type (2)
- Licensing (1)
- Line height (3)
- Logotype (1)
- natural media (1)
- OpenType (1)
- Print design (1)
- Publishing (1)
- Sans serif (1)
- Site roundups (1)
- Subsetting (1)
- Web design (2)
- Z-index (1)
Introduction to Subsetting
Using MyFonts’ webfont kit builder, it’s possible to create a version of the webfont…
Using Webfonts on Publishing Platforms
We often get requests from customers wanting to know how to integrate web fonts into a blog,…
Getting Started with Font Stacks
A font stack is the instruction in a page of CSS code that tells a browser what fonts to display,…