Fonts & counters
The at-rules that define resources the rest of a style sheet refers to by name: web fonts, names for a font's alternate glyphs, custom colour palettes for colour fonts, and custom list counter styles. The properties that use them, such as font-family, font-variant-alternates and font-palette, are under Fonts; list-style is under Lists, tables & content.
Fonts
@font-face
Defines a web font: a family name to use in font-family, where to download the font file, and which weights, styles and characters that file covers. Several @font-face rules with the same family name build one family from several files.
| Syntax | @font-face { <declaration-list> } |
|---|---|
| Support | Chrome 1 · Firefox 3.5 · Safari 3.1 |
| Spec | css-fonts-4 |
| Descriptor | Syntax | Initial | Support |
|---|---|---|---|
ascent-override | [ normal | <percentage [0,∞]> ]{1,2} | normal | Chrome 87 · Firefox 89 · Safari no |
descent-override | [ normal | <percentage [0,∞]> ]{1,2} | normal | Chrome 87 · Firefox 89 · Safari no |
font-display | auto | block | swap | fallback | optional | auto | Chrome 60 · Firefox 58 · Safari 11.1 |
font-family | <font-family-name> | n/a (required) | Chrome 4 · Firefox 3.5 · Safari 3.1 |
font-feature-settings | normal | <feature-tag-value># | normal | Chrome 140 · Firefox 34 · Safari 10 |
font-stretch | The older name for font-width, with the same values | auto | Chrome 62 · Firefox 62 · Safari 10.1 |
font-style | auto | normal | italic | left | right | oblique [ <angle [-90deg,90deg]>{1,2} ]? | auto | Chrome 4 · Firefox 3.5 · Safari 3.1 |
font-variation-settings | normal | [ <string> <number>]# | normal | Chrome 140 · Firefox 62 · Safari no |
font-weight | auto | <font-weight-absolute>{1,2} | auto | Chrome 4 · Firefox 3.5 · Safari 3.1 |
font-width | auto | <'font-width'>{1,2} | auto | Chrome no · Firefox no · Safari 18.4 |
line-gap-override | [ normal | <percentage [0,∞]> ]{1,2} | normal | Chrome 87 · Firefox 89 · Safari no |
size-adjust | <percentage [0,∞]> | 100% | Chrome 92 · Firefox 92 · Safari 17 |
src | <font-src-list> | n/a (required) | Chrome 4 · Firefox 3.5 · Safari 3.1 |
unicode-range | <unicode-range-token># | U+0-10FFFF | Chrome 1 · Firefox 36 · Safari 3.1 |
@font-face {
font-family: "Inter";
src: url("inter.woff2") format("woff2");
font-weight: 100 900;
font-display: swap;
}
body { font-family: "Inter", system-ui, sans-serif; }
src is a comma-separated list tried in order. Each entry is a url(), optionally followed by format() and tech() hints so the browser can skip files it cannot use, or local() to use a font already installed. font-weight, font-style and font-width take two values to declare a range for a variable font.
font-display decides what happens while the file loads: block hides text briefly, swap shows a fallback font at once and swaps when the file arrives, fallback and optional give the file a shorter window and then keep the fallback. size-adjust and the *-override descriptors tune a local fallback font's metrics to match the web font, so text shifts less when the swap happens. unicode-range lists the characters a file covers, and the browser downloads that file only if the page uses one of them.
| Font format or technology | Support |
|---|---|
| WOFF | Chrome 6 · Firefox 3.5 · Safari 5.1 |
| WOFF 2 | Chrome 36 · Firefox 39 · Safari 10 |
| Colour fonts: OpenType COLRv0 | Chrome 53 · Firefox 31 · Safari 11.1 |
| Colour fonts: OpenType COLRv1 | Chrome 98 · Firefox 107 · Safari no |
| Colour fonts: OpenType SVG | Chrome no · Firefox 31 · Safari 12.1 |
| Colour fonts: sbix | Chrome 66 · Firefox no · Safari 9.1 |
| Colour fonts: CBDT/CBLC | Chrome 66 · Firefox no · Safari no |
@font-feature-values
Gives readable names to a font's numbered alternate glyphs, so font-variant-alternates can turn them on by name. Inside it, one block per kind of alternate maps each name to the index the font uses.
| Syntax | @font-feature-values <font-family-name># { <declaration-rule-list> } |
|---|---|
| Support | Chrome 111 · Firefox 34 · Safari 9.1 |
| Spec | css-fonts-4 |
| Feature block | Names values for | OpenType feature | Support |
|---|---|---|---|
@swash | swash() | swsh, cswh | Chrome 111 · Firefox 34 · Safari 9.1 |
@annotation | annotation() | nalt | Chrome 111 · Firefox 34 · Safari 9.1 |
@ornaments | ornaments() | ornm | Chrome 111 · Firefox 34 · Safari 9.1 |
@stylistic | stylistic() | salt | Chrome 111 · Firefox 34 · Safari 9.1 |
@styleset | styleset() | ss01 to ss20 | Chrome 111 · Firefox 34 · Safari 9.1 |
@character-variant | character-variant() | cv01 to cv99 | Chrome 111 · Firefox 34 · Safari 9.1 |
@historical-forms | Historical forms | hist | Chrome 111 · Firefox 34 · Safari 9.1 |
@font-feature-values "Fancy Serif" {
@styleset { alt-g: 2; }
@swash { flourish: 1; }
}
h1 {
font-family: "Fancy Serif";
font-variant-alternates: styleset(alt-g) swash(flourish);
}
The names apply only to the font families listed in the prelude, so the same name can mean a different index in another font.
@font-palette-values
Defines a named colour palette for a colour font: start from one of the palettes built into the font and replace any of its colours. Apply it with font-palette.
| Syntax | @font-palette-values <dashed-ident> { <declaration-list> } |
|---|---|
| Support | Chrome 101 · Firefox 107 · Safari 15.4 |
| Spec | css-fonts-4 |
| Descriptor | Syntax | Initial | Support |
|---|---|---|---|
base-palette | light | dark | <integer [0,∞]> | n/a | Chrome 101 · Firefox 107 · Safari 15.4 |
font-family | <font-family-name># | n/a | Chrome 101 · Firefox 107 · Safari 15.4 |
override-colors | [ <integer [0,∞]> <color> ]# | n/a | Chrome 101 · Firefox 107 · Safari 15.4 |
@font-palette-values --brand {
font-family: "Bungee Spice";
base-palette: 0;
override-colors: 0 #c00, 1 #f80;
}
h1 { font-family: "Bungee Spice"; font-palette: --brand; }
Counters
@counter-style
Defines a custom counter style for list markers and counter(): which symbols to use, how to combine them into numbers, and what goes before and after. Use its name in list-style-type like a built-in style such as decimal.
| Syntax | @counter-style <counter-style-name> { <declaration-list> } |
|---|---|
| Support | Chrome 91 · Firefox 33 · Safari 17 |
| Spec | css-counter-styles-3 |
| Descriptor | Syntax | Initial | Support |
|---|---|---|---|
system | cyclic | numeric | alphabetic | symbolic | additive | [fixed <integer>?] | [ extends <counter-style-name> ] | symbolic | Chrome 91 · Firefox 33 · Safari 17 |
symbols | <symbol>+ | n/a | Chrome 91 · Firefox 33 · Safari 17 |
additive-symbols | [ <integer [0,∞]> && <symbol> ]# | n/a | Chrome 91 · Firefox 33 · Safari 17 |
negative | <symbol> <symbol>? | "-" | Chrome 91 · Firefox 33 · Safari 17 |
prefix | <symbol> | "" | Chrome 91 · Firefox 33 · Safari 17 |
suffix | <symbol> | ". " | Chrome 91 · Firefox 33 · Safari 17 |
range | [ [ <integer> | infinite ]{2} ]# | auto | auto | Chrome 91 · Firefox 33 · Safari 17 |
pad | <integer [0,∞]> && <symbol> | 0 "" | Chrome 91 · Firefox 33 · Safari 17 |
fallback | <counter-style-name> | decimal | Chrome 91 · Firefox 33 · Safari 17 |
speak-as | auto | bullets | numbers | words | spell-out | <counter-style-name> | auto | Chrome 91 · Firefox 33 · Safari no |
@counter-style arrows {
system: cyclic;
symbols: "▸";
suffix: " ";
}
ul.steps { list-style-type: arrows; }
system sets the algorithm: cyclic loops through the symbols, numeric and alphabetic treat them as digits, additive builds values from weighted symbols as Roman numerals do, and extends copies another style and changes only the descriptors you give. A value outside range, or one the system cannot represent, is drawn with the fallback style.