Font-variation-settings - CSS Property
Summary of characteristics of the font-variation-settings property
normalnormalPer grammar: serialization in the order of syntax.Syntax diagram of font-variation-settings.
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:
axeis a 4-character code indicating the chosen axis. It must be written in single or double quotes.numberis 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).
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;
axeis 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.valueis additional information, often numerical. For example, the'wght'(weight) axis requires a value from1to999indicating the thickness of the characters' weight (but that depends on the fonts).In the example, we used the
Google Sans Flexfont which offers quite a few axes:wghtfor the weight of the characters,wdthfor their width,slntfor their slant,RONDfor the ends of the strokes, etc.Samplewght :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'.
Simulator.
With the Google Sans Flex font chosen, you can play around with several aspects:
- The weight (axis
wght), which ranges from1to999. - The width of the characters (axis
wdth), which ranges from25to151. - The tilt (axis
slnt) changes from-10to0. - The rounding of the ends (axis
ROUND) goes from0to100(mostly visible on very bold characters).
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.
font-variation-settings property, which allows access to the different axes of a variable font.font-variation-settingsproperty
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.
Regardingfont-variation-settings:
Initial introduction of thisfont-variation-settingsproperty.July 11, 2017Working Draft.
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:






em, ex, etc.








Functions:

At-rules:



Descriptors :

@font-face. Sets the height of the characters above the baseline.

@font-face. Sets the height of the characters below the baseline.

@font-face. Determines how the browser behaves when faced with fonts that take a long time to load.

@font-face. Sets the line spacing of the font.

@font-face. Defines the range of character codes to be downloaded into a font.


