Font-variation-settings - CSS Property

font-variation-settings

Summary of characteristics of the font-variation-settings property

Quick description
Provides access to the stylistic possibilities of OTF fonts.
Status
Standard
Predefined values
normal
Percentages
Not applicable.
Initial value
normal
Inherited by default
Yes.
See the chapter Animation
Per grammar: serialization in the order of syntax.
W3C Module
CSS Fonts Module
Document status: WD (Working Draft)

Syntax diagram of font-variation-settings.

Font-variation-settings property - Syntax diagramSyntax diagram of the font-variation-settings CSS property. See stylescss.free.fr for details. normal normal 'axe' number 'axe' number , ,font-variation-settings:;font-variation-settings:;
Syntax diagram of the font-variation-settings property.
The links in the diagram provide more details about the values.
Download the diagram.

In the diagram, the bold terms are the predefined words of CSS, the other terms are described below:

  • axe is a 4-character code indicating the chosen axis. It must be written in single or double quotes.
  • number is a unitless number. The range of allowed values depends on the chosen axis.

Description of the font-variation-settings property.

Variable fonts.

Variable fonts offer the ability to change some of their features continuously. That's a big advantage compared to other fonts, which, for example, are either italic or not, or bold or not. With a variable font, you can adjust these settings gradually by specifying a numerical value. Another advantage is the font file size: while regular fonts require a separate file for each style—one for regular, one for bold, one for italic, etc. variable fonts handle everything in the same file.

Variable fonts can be useful for adjusting the width of a headline when it needs to exactly match the width of a column, or for an image caption if it needs to cover the width of the image.

The variable features are called axes and are identified by a four-character string. For example, the 'whgt' axis relates to the weight of the characters, the 'wdth' axis relates to the width of the characters, etc. Watch out! These identifiers are case-sensitive.

Google Fonts has a category for variable fonts, so it’s easy to spot them. Plus, each axis is clearly marked.

Here’s, for example, a demo for the font Google Sans Flex. This font has many axes: 'wght' for weight, 'wdth' for character width, 'slnt' for slant, 'ROND' for rounding at the ends of strokes. In addition, a boolean parameter 'opsz' indicates whether the font can adjust character weight as the size increases (optical sizing). The 'wdth' axis chosen for the example can range from 25 to 151 (values are clipped at these limits).

Demonstration
0 200

The property font-variation-settings.

The CSS property font-variation-settings gives access to these variable font features even if they aren't handled by a specific CSS property, but in some rather rare cases, they can be useful.

font-variation-settings first expects a four-character string (in single or double quotes), which specifies the axis, and then a numeric value, positive or negative. It can also be a decimal number. The minimum and maximum values for this number depend on the chosen font and axis.

Example. Here's how to vary the width of the characters. The axis is wdth (width) and the value can be between 25 and 151, at least for the Google Sans Flex font used.

font-family:'Google Sans Flex'; font-variation-settings:'wdth' 100;

It is of course recommended to use the dedicated property when it exists, as it improves code readability. The use of font-variation-settings should be reserved for very specific cases.

font-variation-settings: 'wght' 500; Can be advantageously replaced by: font-weight: bold;


Also see the font-feature-settings property to adjust a font's non-variable settings.

Values for font-variation-settings.

  • font-variation-settings: normal;

    No font feature is requested. This value can be useful to disable a rule received through inheritance.

  • font-variation-settings: 'axe' valeur;

    axe is the code for one of the many axes of Open Type Features. For example, the 'wdth' axis handles character width, the 'ital' axis handles character slant, etc.

    value is additional information, often numerical. For example, the 'wght' (weight) axis requires a value from 1 to 999 indicating the thickness of the characters' weight (but that depends on the fonts).

    In the example, we used the Google Sans Flex font which offers quite a few axes: wght for the weight of the characters, wdth for their width, slnt for their slant, ROND for the ends of the strokes, etc.

    Sample
    wght :
    wdth :
    slnt :
  • font-variation-settings: 'axe1' valeur1, 'axe2' valeur2;

    Several axes with their values can be specified, separating the axis-value groups with commas.

    If some of the indicated axes are not supported by the font being used, they are simply ignored, without the rule as a whole being considered wrong. In other words, if other axes are specified and are correct, they will be taken into account despite the presence of incorrect axes.

  • font-variation-settings: initial; (normal) font-variation-settings: inherit; font-variation-settings: revert; font-variation-settings: revert-layer; font-variation-settings: revert-rule; font-variation-settings: unset;

    Links to the presentation of these different values: initial, inherit, revert, revert-layer, revert-rule, unset.

Animation of the font-variation-settings property.

Animating the property font-variation-settings is possible as long as the successive steps involve the same axis or axes. For example, if step 1 (from) includes a declaration about the wght axis, then the following steps must also include a declaration for that same axis.
Here, we animated two axes: 'wdht' and 'wght'.

Sample

Simulator.

With the Google Sans Flex font chosen, you can play around with several aspects:

  • The weight (axis wght), which ranges from 1 to 999.
  • The width of the characters (axis wdth), which ranges from 25 to 151.
  • The tilt (axis slnt) changes from -10 to 0.
  • The rounding of the ends (axis ROUND) goes from 0 to 100 (mostly visible on very bold characters).
font-variation-settings :
Sample text

Browsers compatibility with font-variation-settings.

The property font-variation-settings is recognized on its own, but it only affects variable fonts. And besides, the axes supported vary a lot from one font to another.

Column 1
Support for the font-variation-settings property, which allows access to the different axes of a variable font.
1
font-variation-settings
property
Estimated overall support.
97%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Safari

Opéra

Chrome

Firefox

Safari sur IOS

Edge

Androïd Brower

Chrome pour Androïd

Firefox pour Androïd

KaiOS Browser

Opéra mini

Historic of the font-variation-settings property.

  • CSS Fonts Module Level 4

    This level 4 of the specification on fonts reprises what is defined in level 3. It adds the possibility to define what happens when a font takes a long time to load or is missing. It also adds support for colored fonts and clarifies many points still poorly defined in level 3.

    Regarding font-variation-settings:
    Initial introduction of this font-variation-settings property.
    WD
    July 11, 2017
    Working Draft.
    CR
    PR
    REC

See also about fonts.

There are lots of properties related to fonts. They are grouped in the module CSS Fonts Module. You can find the following definitions in this module:

Properties:

font
Langue française
Shorthand to set most properties for fonts.
✗
font-effect
Langue française
Allows you to apply some effects to the text: relief, border...
font-family
Selects a font from those that are available or downloaded.
⚠
font-feature-settings
Langue française
Permet d’exploiter les fonctionnalités spécifiques des polices de caractères OTF, WOFF, etc.
font-kerning
Adjusting the kerning between characters.
⚠
font-language-override
Langue française
Defines the language to be considered when choosing characters.
⚠
font-optical-sizing
Langue française
Optimizes the shape of characters based on their size.
font-palette
Langue française
Defines the color palette that can be used for colored fonts.
font-size
Adjusts the font size, which also impacts units like em, ex, etc.
font-size-adjust
Langue française
Definition of the aspect factor of the font.
✗
font-smooth
Langue française
Defines whether and which smoothing algorithm should be used.
font-stretch
Langue française
Changes the stretching or compression of characters.
font-style
Langue française
Selects the italic or oblique font styles.
font-synthesis
Allows or disallows calculation of missing styles in the typeface.
⚠
font-synthesis-position
Langue française
Whether or not allows the browser to synthesize characters in superscript or subscript.
font-synthesis-small-caps
Langue française
Whether or not allows the browser to calculate the glyphs of characters in small caps.
font-synthesis-style
Langue française
Defines whether the browser is allowed to synthesize italic forms of characters.
font-synthesis-weight
Langue française
Defines whether or not the browser can calculate the bold glyph.
font-variant
Shorthand to define advanced typographic attributes: ligatures, character substitution, etc.
font-variant-alternates
Defines character substitution (OTF, WOFF fonts).
font-variant-caps
Applies character capitalization.
font-variant-east-asian
Typography specific to Chinese or Japanese characters.
⚠
font-variant-emoji
Choose between an emoji or text presentation.
font-variant-ligatures
Enables or disables character ligation.
font-variant-numeric
Defines how evolved numbers are displayed: fractions, numbers, etc.
⚠
font-variant-position
Superscript or subscript of characters.
Font-variation-settings
Provides access to the stylistic possibilities of OTF fonts.
font-weight
Selects a weight for the characters.
font-width
Langue française
Synonymous with font-stretch (character width/enlargement).

Functions:

⚠
palette-mix()
Langue française
Establish the mixture of two color palettes from two different typefaces.

At-rules:

@font-face
Langue française
Defines all settings for a downloadable font.
⚠
@font-feature-values
Langue française
Defines the typographic variations to use.
@font-palette-values
Langue française
Defines a color palette that can then be applied to a font.

Descriptors :

ascent-override
Langue française
Descriptor for @font-face. Sets the height of the characters above the baseline.
descent-override
Langue française
Descriptor for @font-face. Sets the height of the characters below the baseline.
⚠
font-display
Langue française
Descriptor for @font-face. Determines how the browser behaves when faced with fonts that take a long time to load.
line-gap-override
Langue française
Descriptor for @font-face. Sets the line spacing of the font.
src
Langue française
Defines the source of a font file to download, or an image to display.
unicode-range
Langue française
Descriptor for @font-face. Defines the range of character codes to be downloaded into a font.