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> }
SupportChrome 1 · Firefox 3.5 · Safari 3.1
Speccss-fonts-4
DescriptorSyntaxInitialSupport
ascent-override[ normal | <percentage [0,∞]> ]{1,2}normalChrome 87 · Firefox 89 · Safari no
descent-override[ normal | <percentage [0,∞]> ]{1,2}normalChrome 87 · Firefox 89 · Safari no
font-displayauto | block | swap | fallback | optionalautoChrome 60 · Firefox 58 · Safari 11.1
font-family<font-family-name>n/a (required)Chrome 4 · Firefox 3.5 · Safari 3.1
font-feature-settingsnormal | <feature-tag-value>#normalChrome 140 · Firefox 34 · Safari 10
font-stretchThe older name for font-width, with the same valuesautoChrome 62 · Firefox 62 · Safari 10.1
font-styleauto | normal | italic | left | right | oblique [ <angle [-90deg,90deg]>{1,2} ]?autoChrome 4 · Firefox 3.5 · Safari 3.1
font-variation-settingsnormal | [ <string> <number>]#normalChrome 140 · Firefox 62 · Safari no
font-weightauto | <font-weight-absolute>{1,2}autoChrome 4 · Firefox 3.5 · Safari 3.1
font-widthauto | <'font-width'>{1,2}autoChrome no · Firefox no · Safari 18.4
line-gap-override[ normal | <percentage [0,∞]> ]{1,2}normalChrome 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-10FFFFChrome 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; }
One variable font file covering every weight from 100 to 900.

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 technologySupport
WOFFChrome 6 · Firefox 3.5 · Safari 5.1
WOFF 2Chrome 36 · Firefox 39 · Safari 10
Colour fonts: OpenType COLRv0Chrome 53 · Firefox 31 · Safari 11.1
Colour fonts: OpenType COLRv1Chrome 98 · Firefox 107 · Safari no
Colour fonts: OpenType SVGChrome no · Firefox 31 · Safari 12.1
Colour fonts: sbixChrome 66 · Firefox no · Safari 9.1
Colour fonts: CBDT/CBLCChrome 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> }
SupportChrome 111 · Firefox 34 · Safari 9.1
Speccss-fonts-4
Feature blockNames values forOpenType featureSupport
@swashswash()swsh, cswhChrome 111 · Firefox 34 · Safari 9.1
@annotationannotation()naltChrome 111 · Firefox 34 · Safari 9.1
@ornamentsornaments()ornmChrome 111 · Firefox 34 · Safari 9.1
@stylisticstylistic()saltChrome 111 · Firefox 34 · Safari 9.1
@stylesetstyleset()ss01 to ss20Chrome 111 · Firefox 34 · Safari 9.1
@character-variantcharacter-variant()cv01 to cv99Chrome 111 · Firefox 34 · Safari 9.1
@historical-formsHistorical formshistChrome 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);
}
Name stylistic set 2 and swash 1, then use them by name.

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> }
SupportChrome 101 · Firefox 107 · Safari 15.4
Speccss-fonts-4
DescriptorSyntaxInitialSupport
base-palettelight | dark | <integer [0,∞]>n/aChrome 101 · Firefox 107 · Safari 15.4
font-family<font-family-name>#n/aChrome 101 · Firefox 107 · Safari 15.4
override-colors[ <integer [0,∞]> <color> ]#n/aChrome 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; }
Start from the font's first palette and replace its first two colours.

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> }
SupportChrome 91 · Firefox 33 · Safari 17
Speccss-counter-styles-3
DescriptorSyntaxInitialSupport
systemcyclic | numeric | alphabetic | symbolic | additive | [fixed <integer>?] | [ extends <counter-style-name> ]symbolicChrome 91 · Firefox 33 · Safari 17
symbols<symbol>+n/aChrome 91 · Firefox 33 · Safari 17
additive-symbols[ <integer [0,∞]> && <symbol> ]#n/aChrome 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} ]# | autoautoChrome 91 · Firefox 33 · Safari 17
pad<integer [0,∞]> && <symbol>0 ""Chrome 91 · Firefox 33 · Safari 17
fallback<counter-style-name>decimalChrome 91 · Firefox 33 · Safari 17
speak-asauto | bullets | numbers | words | spell-out | <counter-style-name>autoChrome 91 · Firefox 33 · Safari no
@counter-style arrows {
  system: cyclic;
  symbols: "▸";
  suffix: " ";
}

ul.steps { list-style-type: arrows; }
A bullet style that repeats one symbol for every item.

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.