CSS font-variation-settings Property
The font-variation-settings property provides direct control over the variation axes available in a variable font.
Variable fonts can contain multiple variations of a typeface within a single font file. This property allows you to adjust supported axes such as weight, width, slant, optical size, and font-specific design characteristics using four-character axis tags and numeric values.
font-variation-settings Syntax
The property accepts normal or a comma-separated list of variation axis settings. Each setting contains a quoted four-character axis tag followed by a number.
Basic Syntax
selector {
font-variation-settings: normal;
}
Weight Axis
selector {
font-variation-settings: "wght" 600;
}
Width Axis
selector {
font-variation-settings: "wdth" 85;
}
Multiple Axes
selector {
font-variation-settings: "wght" 650, "wdth" 90;
}
Custom Axis
selector {
font-variation-settings: "GRAD" 50;
}
CSS-Wide Keywords
.example {
font-variation-settings: inherit;
}
.example {
font-variation-settings: initial;
}
.example {
font-variation-settings: unset;
}
.example {
font-variation-settings: revert;
}
.example {
font-variation-settings: revert-layer;
}
Axis tags are case-sensitive and must contain exactly four ASCII characters. The selected font must support the requested axis for the setting to affect its appearance.
Property Values
The property uses the following value types.
| Value | Description |
|---|---|
normal |
Does not specify any low-level variation axis settings. |
"axis" number |
Sets a numeric value for the named four-character variation axis. |
"axis" number, "axis" number |
Sets multiple variation axes in one declaration. |
inherit |
Uses the computed value from the parent element. |
initial |
Resets the property to normal. |
unset |
Acts as inherit because this property is inherited. |
revert |
Reverts the property according to the CSS cascade origin. |
revert-layer |
Reverts the property according to the previous cascade layer. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | normal |
| Inherited | Yes |
| Applies to | All elements and text |
| Computed value | As specified |
| Animation type | By computed value type, with compatible axis lists interpolated numerically |
| Percentages | Not applicable |
Variation values are unitless numbers. Their valid design ranges depend on the selected font, not on a universal CSS scale.
How It Works
A variable font contains one or more design axes. Each axis represents a characteristic that can change continuously or between supported design positions.
Select a Variable Font
.variable-heading {
font-family: "Example Variable", sans-serif;
}
Adjust an Axis
.variable-heading {
font-variation-settings: "wght" 700;
}
Adjust Two Axes
.variable-heading {
font-variation-settings: "wght" 700, "wdth" 85;
}
Axis Values
The browser passes each requested axis value to the font rendering system. The font defines the available range and the appearance of each variation.
Values Outside the Supported Range
When a value falls outside an axis's supported range, the font rendering system uses an appropriate supported limit rather than extending the design indefinitely.
Unsupported Axes
If a font does not contain a requested axis, that setting cannot change the font's appearance.
Important Consideration
Setting an axis does not guarantee a visible difference. The result depends on the font's available variations and the selected axis values.
Variable Font Axes
Variable fonts can provide registered axes and custom axes. Registered axes have standardized tags and meanings.
Common Registered Axes
| Axis Tag | Name | Purpose |
|---|---|---|
"wght" |
Weight | Controls the weight of the typeface. |
"wdth" |
Width | Controls the width of the typeface. |
"slnt" |
Slant | Controls the slant angle of supported glyph designs. |
"ital" |
Italic | Controls the font's italic design axis. |
"opsz" |
Optical size | Adjusts the design for different text sizes. |
Custom Axes
Font designers may provide additional axes with font-specific tags, such as grade, contrast, or decorative details.
Axis Tags Are Case-Sensitive
The registered tags use lowercase letters. Custom axis tags commonly begin with uppercase letters.
Check the Font Documentation
Before using a variation axis, confirm its exact tag, default value, and supported range in the font's documentation.
Weight Axis
The "wght" axis controls the weight of a variable font, ranging from lighter to heavier designs within the font's supported range.
Basic Example
.heading {
font-variation-settings: "wght" 700;
}
Different Weight Values
.light {
font-variation-settings: "wght" 300;
}
.medium {
font-variation-settings: "wght" 500;
}
.bold {
font-variation-settings: "wght" 800;
}
Compare with font-weight
.heading {
font-weight: 700;
}
For standard weight control, font-weight is generally preferred because it works with both variable and traditional font families.
Supported Range
A font might support weights from 100 to 900, or a narrower range. The available range must be checked for the specific font.
Important Consideration
A low-level "wght" setting can take precedence over the variation coordinates normally selected through font-weight. Avoid conflicting values unless direct axis control is intentional.
Width Axis
The "wdth" axis controls the width of a variable font's glyph designs.
Basic Example
.condensed-heading {
font-variation-settings: "wdth" 75;
}
Different Width Values
.narrow {
font-variation-settings: "wdth" 75;
}
.standard {
font-variation-settings: "wdth" 100;
}
.wide {
font-variation-settings: "wdth" 125;
}
Compare with font-stretch
.condensed-heading {
font-stretch: 75%;
}
The font-stretch property, also described as font-width in newer CSS Fonts specifications, provides a high-level way to request condensed or expanded font designs.
Width Is Not Scaling
A variable font's width axis can change glyph outlines and spacing in ways specifically designed by the typeface creator. This differs from applying a CSS transform that stretches the rendered text.
Important Consideration
Not all fonts support width values such as 75 or 125. Use values documented for the selected font.
Slant Axis
The "slnt" axis controls the slant angle of a variable font that supports slanted designs.
Basic Example
.slanted-text {
font-variation-settings: "slnt" -10;
}
Different Slant Values
.upright {
font-variation-settings: "slnt" 0;
}
.slight-slant {
font-variation-settings: "slnt" -5;
}
.strong-slant {
font-variation-settings: "slnt" -12;
}
Compare with font-style
.slanted-text {
font-style: oblique 10deg;
}
The font-style property provides a higher-level way to request italic or oblique text.
Slant Direction
The meaning and available range of the axis follow the font's design. In commonly used slant axes, negative values produce a rightward slant.
Important Consideration
The "slnt" axis is not available in every variable font. It should not be confused with the separate "ital" axis.
Italic Axis
The "ital" axis selects italic design variations in fonts that provide this registered axis.
Basic Example
.italic-text {
font-variation-settings: "ital" 1;
}
Upright Design
.upright-text {
font-variation-settings: "ital" 0;
}
Compare with font-style
.italic-text {
font-style: italic;
}
Italic vs. Slant
An italic design may use different letterforms, not simply slanted upright characters. The "slnt" axis controls slant, while "ital" identifies italic design variation.
Supported Values
The registered italic axis normally uses 0 for upright and 1 for italic. Its exact implementation depends on the font.
Important Consideration
Use font-style: italic for ordinary italic text. Direct "ital" control is most useful when working with a font that explicitly exposes this axis.
Optical Size Axis
The "opsz" axis adjusts glyph designs for different optical sizes, potentially changing details such as stroke contrast, spacing, and letterform proportions.
Basic Example
.small-text {
font-variation-settings: "opsz" 12;
}
Display Text
.display-heading {
font-variation-settings: "opsz" 48;
}
Compare with font-optical-sizing
.text {
font-optical-sizing: auto;
}
Automatic Optical Sizing
When supported by the font, font-optical-sizing: auto allows the browser to select optical size based on the text's rendered size.
Manual Optical Sizing
.heading {
font-optical-sizing: none;
font-variation-settings: "opsz" 48;
}
Important Consideration
The optical size axis is not the same as font-size. It changes the design of glyphs rather than directly setting their displayed size.
Use automatic optical sizing for typical responsive typography and manual axis values when a specific design variation is required.
Custom Variation Axes
Variable fonts may contain custom axes that control characteristics beyond the standard registered axes.
Grade Axis
.graded-text {
font-variation-settings: "GRAD" 50;
}
Some fonts use a grade axis to adjust stroke thickness while minimizing changes to character widths.
Custom Design Axis
.decorative-text {
font-variation-settings: "XTRA" 450;
}
The "XTRA" tag is used by certain variable fonts for a design dimension related to counter or letterform proportions. Its effect depends on the font.
Combining Custom and Registered Axes
.custom-heading {
font-variation-settings: "wght" 650, "GRAD" 50;
}
Custom Tags
Custom axis tags are font-specific and commonly use uppercase letters. The exact spelling and capitalization must match the font's axis definition.
Important Consideration
Custom axes are not universally available. A setting that works with one font may have no effect with another.
Combining Multiple Axes
Multiple variation axes can be set in a single declaration using comma-separated settings.
Weight and Width
.heading {
font-variation-settings: "wght" 700, "wdth" 85;
}
Weight, Width, and Slant
.heading {
font-variation-settings: "wght" 650, "wdth" 90, "slnt" -8;
}
Weight and Optical Size
.heading {
font-variation-settings: "wght" 700, "opsz" 48;
}
Registered and Custom Axes
.heading {
font-variation-settings: "wght" 650, "GRAD" 25;
}
Replacing an Axis List
.heading {
font-variation-settings: "wght" 650, "wdth" 90;
}
.heading:hover {
font-variation-settings: "wght" 800;
}
The hover declaration replaces the entire low-level variation settings list. The earlier "wdth" setting is not retained.
Preserving All Axes
.heading:hover {
font-variation-settings: "wght" 800, "wdth" 90;
}
Important Consideration
Every declared axis must be supported by the selected font to affect its appearance. Unsupported axes do not invalidate otherwise valid settings.
Using Variable Web Fonts
Variable fonts can be loaded with @font-face, allowing a website to use supported variation ranges from a single font resource.
Define a Variable Font
@font-face {
font-family: "Example Variable";
src: url("/fonts/example-variable.woff2") format("woff2");
font-weight: 100 900;
font-style: normal;
font-display: swap;
}
Apply the Font
.variable-text {
font-family: "Example Variable", sans-serif;
}
Set a Variation Axis
.variable-text {
font-variation-settings: "wght" 650;
}
Using High-Level Weight Control
.variable-text {
font-weight: 650;
}
Multiple Supported Axes
.variable-text {
font-variation-settings: "wght" 650, "wdth" 90;
}
Font Descriptor Ranges
The @font-face descriptors should accurately describe the font's supported style ranges. For example, a variable font supporting weights from 300 to 800 should not be declared as supporting weights outside that range.
Important Consideration
The example font URL is illustrative. Replace it with the actual path to a variable font and use axis values supported by that font.
High-Level Font Properties
CSS provides high-level properties for several common font characteristics. These are generally preferred over direct axis settings when they can express the desired result.
Weight
.heading {
font-weight: 700;
}
Width
.heading {
font-stretch: 85%;
}
Italic
.heading {
font-style: italic;
}
Oblique
.heading {
font-style: oblique 10deg;
}
Optical Sizing
.heading {
font-optical-sizing: auto;
}
Direct Axis Control
.heading {
font-variation-settings: "wght" 700, "wdth" 85;
}
Comparison
| High-Level Property | Related Axis |
|---|---|
font-weight |
"wght" |
font-stretch |
"wdth" |
font-style |
"ital" or "slnt" |
font-optical-sizing |
"opsz" |
Important Consideration
Low-level variation settings can override the corresponding axis values selected by high-level properties. Use direct settings primarily for custom axes or when precise control is needed.
Animating Variable Fonts
Variation axis values can be animated when the browser and selected font support the requested changes.
Weight Transition
.animated-heading {
font-variation-settings: "wght" 400;
transition: font-variation-settings 300ms ease;
}
.animated-heading:hover {
font-variation-settings: "wght" 800;
}
Multiple Axis Transition
.animated-heading {
font-variation-settings: "wght" 400, "wdth" 100;
transition: font-variation-settings 400ms ease;
}
.animated-heading:hover {
font-variation-settings: "wght" 750, "wdth" 85;
}
Keyframe Animation
@keyframes variable-weight {
from {
font-variation-settings: "wght" 300;
}
to {
font-variation-settings: "wght" 800;
}
}
.animated-text {
animation: variable-weight 2s ease-in-out infinite alternate;
}
Matching Axis Lists
For smooth interpolation, use matching axis tags in the starting and ending values. If the axis lists are incompatible, the change may be discrete instead of gradual.
Reduced Motion
@media (prefers-reduced-motion: reduce) {
.animated-heading {
transition: none;
}
.animated-text {
animation: none;
}
}
Important Consideration
Animating font variations can change text dimensions and cause layout movement. Test animations with the actual font and avoid unnecessary continuous motion.
Inheritance
The font-variation-settings property is inherited. Child elements receive the parent's variation settings unless they specify another value.
Inherited Settings
.variable-section {
font-variation-settings: "wght" 600;
}
<div class="variable-section">
<h2>Section Heading</h2>
<p>Variable font text.</p>
</div>
Override a Child Element
.variable-section {
font-variation-settings: "wght" 600;
}
.variable-section .light-text {
font-variation-settings: "wght" 300;
}
Explicit Inheritance
.child {
font-variation-settings: inherit;
}
Reset to Initial Value
.child {
font-variation-settings: initial;
}
Important Consideration
Inherited axis settings may affect headings, paragraphs, buttons, and other text. Apply variation settings to appropriately scoped elements when different components require different typography.
font-variation-settings Example
This example demonstrates the syntax for variable font axes using weight, width, and slant settings. A variable font supporting these axes is required for the intended differences to appear.
HTML Example
<div class="font-variation-demo">
<p class="demo-label">Normal font settings</p>
<p class="demo-normal">Variable Typography</p>
<p class="demo-label">Weight axis: 700</p>
<p class="demo-weight">Variable Typography</p>
<p class="demo-label">Width axis: 85</p>
<p class="demo-width">Variable Typography</p>
<p class="demo-label">Weight and slant axes</p>
<p class="demo-combined">Variable Typography</p>
</div>
CSS Example
.font-variation-demo {
font-family: "Example Variable", sans-serif;
}
.font-variation-demo .demo-label {
margin: 0 0 6px;
font: 600 13px/1.4 Arial, sans-serif;
}
.font-variation-demo .demo-normal,
.font-variation-demo .demo-weight,
.font-variation-demo .demo-width,
.font-variation-demo .demo-combined {
margin: 0 0 20px;
font-size: 28px;
line-height: 1.4;
}
.font-variation-demo .demo-normal {
font-variation-settings: normal;
}
.font-variation-demo .demo-weight {
font-variation-settings: "wght" 700;
}
.font-variation-demo .demo-width {
font-variation-settings: "wdth" 85;
}
.font-variation-demo .demo-combined {
font-variation-settings: "wght" 650, "slnt" -10;
}
Normal font settings
Variable Typography
Weight axis: 700
Variable Typography
Width axis: 85
Variable Typography
Weight and slant axes
Variable Typography
The example uses a placeholder font family. To see the intended variation effects, load an actual variable font and replace "Example Variable" with its declared family name.
The weight, width, and slant values must also fall within the ranges supported by that font. Without a suitable variable font, the examples may appear identical.
Common Mistakes
Common mistakes involve incorrect axis tags, unsupported fonts, and conflicts with high-level font properties.
Using an Unquoted Axis Tag
.heading {
font-variation-settings: wght 700;
}
This declaration is invalid. Axis tags must be quoted strings.
Using the Wrong Number of Characters
.heading {
font-variation-settings: "weight" 700;
}
This declaration is invalid because an axis tag must contain exactly four characters.
Using the Wrong Capitalization
.heading {
font-variation-settings: "WGHT" 700;
}
Axis tags are case-sensitive. The registered weight axis uses "wght", not "WGHT".
Forgetting Commas
.heading {
font-variation-settings: "wght" 700 "wdth" 85;
}
This declaration is invalid because multiple axis settings must be separated by commas.
Using a Non-Variable Font
Traditional static fonts generally do not provide variation axes, so direct variation settings may have no visible effect.
Assuming Every Font Supports the Same Axes
A font may support weight but not width, slant, optical size, or custom axes.
Assuming Universal Axis Ranges
Axis ranges vary by font. A width value of 75 or a weight value of 900 may not be available in the selected typeface.
Overriding High-Level Font Properties
A low-level "wght" setting can override the weight normally selected by font-weight. Avoid conflicting values.
Forgetting That Declarations Replace the List
A later font-variation-settings declaration replaces the earlier axis list rather than adding to it.
Animating Different Axis Lists
Animations may not interpolate smoothly when the starting and ending declarations contain different axis tags.
Important Considerations
Keep the following points in mind when using the font-variation-settings property:
- Purpose: Provides low-level control over variable font axes.
- Initial value:
normal. - Inheritance: The property is inherited.
- Applies to: All elements and text.
- Axis tags: Must be quoted strings containing exactly four ASCII characters.
- Case sensitivity: Axis tags are case-sensitive.
- Numeric values: Axis values are unitless numbers.
- Multiple axes: Separate settings with commas.
- Weight axis:
"wght"controls supported weight variations. - Width axis:
"wdth"controls supported width variations. - Slant axis:
"slnt"controls supported slant variations. - Italic axis:
"ital"controls supported italic design variations. - Optical size axis:
"opsz"controls optical design variations. - Custom axes: Fonts may provide additional font-specific controls.
- Font support: The selected font must contain the requested variation axes.
- Axis ranges: Valid design ranges depend on the font.
- High-level properties: Prefer
font-weight,font-style, and other standard font properties when appropriate. - Conflicting controls: Low-level axis settings may override corresponding high-level controls.
- Animations: Compatible axis lists can transition smoothly between numeric values.
- Reduced motion: Respect the user's motion preferences when animating text.
- Fallback fonts: Fonts without the requested axes may display no visible variation.
- Browser support: Check compatibility and variable font support.
Use font-variation-settings when precise axis control or custom font variations are needed. For ordinary typography, high-level font properties usually provide a simpler and more flexible solution.
Browser Support
The CSS font-variation-settings property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.
The visible effects depend on the selected font's variation axes and supported ranges.
Basic Example
.heading {
font-variation-settings: "wght" 700;
}
Feature Detection
@supports (font-variation-settings: "wght" 700) {
.heading {
font-variation-settings: "wght" 700;
}
}
Progressive Enhancement
.heading {
font-weight: 700;
}
@supports (font-variation-settings: "wght" 700) {
.heading {
font-variation-settings: "wght" 700;
}
}
Font Axis Availability
The @supports rule checks whether the browser recognizes the CSS declaration. It does not confirm that the selected font includes the requested variation axis.
For current compatibility information, visit Can I Use? and search for font-variation-settings.
Specifications
The font-variation-settings property is defined in the CSS Fonts Module, which describes variable font axes and low-level font variation controls.
CSS Fonts Module Level 4: font-variation-settings
The module also defines related font properties, including weight, style, width, and optical sizing controls.
For additional explanations and examples, see MDN Web Docs.
