Fonts

The properties that choose a font and the glyphs drawn from it: family, size, weight, style and width, the font-variant family of typographic features, low-level OpenType feature and variation controls, colour palettes and the browser's fallback synthesis. Loading a web font is done with @font-face. Spacing, wrapping, decoration and line height are under Text; the text colour is under Color & backgrounds.

The font shorthand

font

Sets the main font properties in one declaration. The size and family are required and come last, in that order; style, small caps, weight and width may come first in any order, and a line height may follow the size after a slash.

Syntax[ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-font-family-name>
InitialSee individual properties
Applies toAll elements and text
InheritedYes
PercentagesSee individual properties
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-fonts-4

<font-variant-css2> is just normal or small-caps, and <font-width-css3> is one of the width keywords such as condensed. <system-font-family-name> is one of caption, icon, menu, message-box, small-caption or status-bar, which copy the font the operating system uses for that part of its interface.

Any longhand you leave out is reset to its initial value, so font also clears an inherited line-height. It resets font-size-adjust, font-kerning and the font-variant longhands too, even though it cannot set them.

font: italic 600 1.125rem / 1.5 system-ui, sans-serif;
Style, weight, size, line height and family in one declaration.

Family, size & weight

font-family

A comma-separated list of fonts to try in order. For each character the browser uses the first font in the list that has a glyph for it, so the list should end with a generic family.

Syntax[ <font-family-name> | <generic-font-family> ]#
InitialDepends on the browser
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-fonts-4

A <font-family-name> is a quoted string or a sequence of identifiers; quote any name that contains spaces or punctuation. Generic families include serif, sans-serif, monospace, cursive, system-ui, math and emoji. Generic names must not be quoted, or they are treated as a font called, for example, "serif".

font-family: "Source Serif 4", Georgia, serif;
A web font, a widely installed fallback, then the generic family.

font-size

The size of the font, which also sets the value of the em unit for the element. Keywords from xx-small to xxx-large pick from a browser scale based on medium; larger and smaller step relative to the parent.

Syntax<absolute-size> | <relative-size> | <length-percentage [0,∞]> | math
Initialmedium
Applies toAll elements and text
InheritedYes
PercentagesRefer to the parent element's font size
AnimationBy computed value type
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-fonts-4

em and percentages are relative to the parent's font size, so they compound when nested; rem is relative to the root element and does not. math scales the size by the nesting level given in math-depth, for MathML.

font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
Fluid body text that grows with the viewport between two limits.

font-weight

How heavy the strokes of the font are, as a number from 1 to 1000. normal is 400 and bold is 700; bolder and lighter step relative to the inherited weight.

Syntax<font-weight-absolute> | bolder | lighter
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationBy computed value type
SupportChrome 2 · Firefox 1 · Safari 1
Speccss-fonts-4

<font-weight-absolute> is normal, bold or a number in the range 1 to 1000. A variable font can draw any weight in its range; a static family uses the nearest face it has, and the browser may synthesise bold if there is none (see font-synthesis).

font-style

Chooses an italic or oblique face. oblique takes an optional slant angle, which a variable font with a slant axis can match exactly.

Syntaxnormal | italic | left | right | oblique <angle [-90deg,90deg]>?
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationBy computed value type; normal animates as oblique 0deg
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-fonts-4

If the family has no italic, the browser falls back to an oblique face, and then to slanting the upright face itself unless font-synthesis-style forbids it.

font-width

Chooses a narrower or wider face of the family, as a keyword or a percentage of the normal width.

Syntaxnormal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
Initialnormal
Applies toAll elements and text
InheritedYes
PercentagesNot resolved; the percentage is the width itself, where 100% is normal
AnimationBy computed value type
SupportChrome no · Firefox 155 · Safari 18.4
Speccss-fonts-4

font-width is the new name for font-stretch, which remains a legacy alias and is supported in every browser (Chrome 60, Firefox 9, Safari 11). Until Chrome accepts the new name, font-stretch is the one to use. The keywords run from ultra-condensed (50%) to ultra-expanded (200%). It only has an effect if the family has width variants or a width axis; browsers never stretch glyphs artificially.

font-size-adjust

Keeps a chosen font metric the same size across fonts, so a fallback font with a smaller x-height does not look smaller than the font it replaces.

Syntaxnone | [ ex-height | cap-height | ch-width | ic-width | ic-height ]? [ from-font | <number [0,∞]> ]
Initialnone
Applies toAll elements and text
InheritedYes
AnimationDiscrete if the keywords differ, otherwise by computed value type
SupportChrome 127 · Firefox 3 · Safari 16.4
Speccss-fonts-5

The number is the wanted ratio of the metric to the font size; the metric defaults to ex-height. from-font takes the ratio from the first font in the list, so every fallback is scaled to match it.

font-size-adjust: from-font;
Fallback fonts are scaled to the primary font's x-height.

Variants

font-variant

Shorthand for the seven font-variant-* longhands below, which switch on the alternative glyphs a font provides: small capitals, figure styles, ligatures, East Asian forms, stylistic alternates, sub and superscripts and emoji presentation.

Syntaxnormal | none | [ [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ] || [ small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps ] || [ stylistic(<font-feature-value-name>) || historical-forms || styleset(<font-feature-value-name>#) || character-variant(<font-feature-value-name>#) || swash(<font-feature-value-name>) || ornaments(<font-feature-value-name>) || annotation(<font-feature-value-name>) ] || [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero ] || [ <east-asian-variant-values> || <east-asian-width-values> || ruby ] || [ sub | super ] || [ text | emoji | unicode ] ]
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-fonts-4

normal resets every longhand; none does the same but also turns off the font's standard ligatures. The early versions listed for support cover only small-caps; the other values arrived with each longhand.

font-variant-caps

Uses the font's small capital, petite capital or titling capital glyphs. If the font has no small capitals, the browser makes them by shrinking capital letters.

Syntaxnormal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 52 · Firefox 34 · Safari 9.1
Speccss-fonts-4

small-caps replaces lowercase letters only; all-small-caps replaces capitals as well, which suits acronyms set in running text.

font-variant-numeric

Chooses the style of digits and fractions: lining or old-style figures, proportional or fixed-width (tabular) spacing, diagonal or stacked fractions, ordinal suffixes and a slashed zero.

Syntaxnormal | [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero ]
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 52 · Firefox 34 · Safari 9.1
Speccss-fonts-4

The groups are lining-nums or oldstyle-nums, proportional-nums or tabular-nums, and diagonal-fractions or stacked-fractions. Each only works if the font includes those glyphs.

td.amount { font-variant-numeric: tabular-nums; }
Every digit takes the same width, so columns of numbers line up.

font-variant-ligatures

Turns groups of ligatures and contextual alternates on or off. Common ligatures such as "fi" and contextual alternates are on by default; discretionary and historical ligatures are off.

Syntaxnormal | none | [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ]
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 34 · Firefox 34 · Safari 9.1
Speccss-fonts-4

Each group has an on and off keyword: common-ligatures / no-common-ligatures, discretionary-ligatures / no-discretionary-ligatures, historical-ligatures / no-historical-ligatures and contextual / no-contextual. none turns them all off, which is common for code.

font-variant-east-asian

Chooses East Asian glyph forms: the character standard to follow (jis78, jis83, jis90, jis04, simplified, traditional), full-width or proportional width, and the smaller forms designed for ruby.

Syntaxnormal | [ <east-asian-variant-values> || <east-asian-width-values> || ruby ]
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 63 · Firefox 34 · Safari 9.1
Speccss-fonts-4

The width values are full-width and proportional-width.

font-variant-alternates

Switches on a font's stylistic alternates, style sets, character variants, swashes, ornaments and annotation forms. Apart from historical-forms, each function takes a name that you map to the font's own index in an @font-feature-values rule.

Syntaxnormal | [ stylistic(<font-feature-value-name>) || historical-forms || styleset(<font-feature-value-name>#) || character-variant(<font-feature-value-name>#) || swash(<font-feature-value-name>) || ornaments(<font-feature-value-name>) || annotation(<font-feature-value-name>) ]
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 111 · Firefox 34 · Safari 9.1
Speccss-fonts-4
@font-feature-values Fraunces { @styleset { rounded: 2; } }
h1 { font-variant-alternates: styleset(rounded); }
A readable name for the font's second style set.

font-variant-position

Uses the font's purpose-drawn subscript or superscript glyphs. Unlike vertical-align: sub, it does not change the line height or shift the baseline.

Syntaxnormal | sub | super
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 117 · Firefox 34 · Safari 9.1
Speccss-fonts-4

font-variant-emoji

Chooses between the colourful emoji presentation and the plain text presentation for characters that have both, such as ☺ or ♥.

Syntaxnormal | text | emoji | unicode
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 131 · Firefox 141 · Safari no
Speccss-fonts-4

unicode follows each character's default presentation in Unicode; normal leaves the choice to the browser. A variation selector in the text itself always wins.

Low-level features

font-feature-settings

Turns OpenType features on or off directly by their four-letter tags. Use it for features that have no font-variant-* keyword; where one exists, the keyword is easier to read and combines better.

Syntaxnormal | <feature-tag-value>#
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 48 · Firefox 34 · Safari 9.1
Speccss-fonts-4

Each <feature-tag-value> is a quoted tag followed by on, off or a number (1 if omitted). The whole list replaces any inherited one, so a child that sets one feature loses the features its parent set.

font-feature-settings: "ss01", "cv05" 1, "kern" off;
Style set 1 and character variant 5 on, kerning off.

font-variation-settings

Sets the axes of a variable font directly by their four-letter tags. Prefer font-weight, font-width, font-style and font-optical-sizing for the standard axes, and use this for a font's custom axes.

Syntaxnormal | [ <opentype-tag> <number> ]#
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationEach axis value interpolates when both lists name the same axes; otherwise discrete
SupportChrome 62 · Firefox 62 · Safari 11
Speccss-fonts-4

Registered axes have lowercase tags ("wght", "wdth", "slnt", "ital", "opsz"); custom axes are uppercase, such as "GRAD". Like font-feature-settings, the list replaces any inherited one.

font-variation-settings: "GRAD" 150;
A custom grade axis, which thickens strokes without changing width.

font-optical-sizing

Whether the browser sets a variable font's optical size axis to match the font size, giving small text sturdier shapes and large text finer detail. none turns this off.

Syntaxauto | none
Initialauto
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 79 · Firefox 62 · Safari 13.1
Speccss-fonts-4

font-kerning

Whether the font's kerning data is used to adjust the spacing between particular pairs of letters. auto lets the browser decide, normal forces kerning on and none turns it off.

Syntaxauto | normal | none
Initialauto
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 33 · Firefox 32 · Safari 9
Speccss-fonts-4

font-language-override

Tells the font which language's glyph forms to use, as an OpenType language system tag such as "TRK", instead of deriving it from the element's lang.

Syntaxnormal | <string>
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 143 · Firefox 34 · Safari no
Speccss-fonts-4

Setting the correct lang attribute is usually the better fix; this property is for content whose language is marked up wrongly or not at all.

font-palette

Chooses which of a colour font's palettes to draw with. light and dark pick the palettes the font marks as suited to light or dark backgrounds; a dashed name refers to a palette defined or overridden with @font-palette-values.

Syntaxnormal | light | dark | <palette-identifier> | <palette-mix()>
Initialnormal
Applies toAll elements and text
InheritedYes
AnimationBy computed value
SupportChrome 101 · Firefox 107 · Safari 15.4
Speccss-fonts-4

<palette-identifier> is a <dashed-ident> such as --brand. palette-mix() blends two palettes, which is how a change of palette is animated.

Synthesis

font-synthesis

Shorthand that lists which faces the browser may fake when the family lacks them: bold (weight), italic or oblique (style), small capitals (small-caps) and sub and superscript glyphs (position). Anything left out of the list is not synthesised; none forbids all four.

Syntaxnone | [ weight || style || small-caps || position]
Initialweight style small-caps position
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 97 · Firefox 34 · Safari 9
Speccss-fonts-4

Turning synthesis off is useful for scripts such as Chinese or Japanese, where faked bold or slanted glyphs are hard to read.

:lang(ja) { font-synthesis: none; }
No faked bold or italic for Japanese text.

font-synthesis-style

Whether the browser may slant the upright face when the family has no italic or oblique face. none keeps the text upright instead.

Syntaxauto | none | oblique-only
Initialauto
Applies toAll elements and text
InheritedYes
AnimationDiscrete
SupportChrome 97 · Firefox 111 · Safari 16.4
Speccss-fonts-4

font-synthesis-weight, font-synthesis-small-caps, font-synthesis-position

Whether the browser may fake a bold face, small capitals, or sub and superscript glyphs respectively, when the family does not provide them. auto allows it and none forbids it.

Syntaxauto | none
Initialauto
Applies toAll elements and text
InheritedYes
AnimationDiscrete
Supportfont-synthesis-weight: Chrome 97 · Firefox 111 · Safari 16.4
font-synthesis-small-caps: Chrome 97 · Firefox 111 · Safari 16.4
font-synthesis-position: Chrome no · Firefox 118 · Safari no
Speccss-fonts-4