The font-variation-settings Property
You'll learn how to use font-variation-settings to control variable font axes and create custom typographic variations.
What Is This Property?
The font-variation-settings property is your direct dial for controlling variable font axes. Think of it like adjusting sliders on a sound mixer—each axis (weight, width, slant, optical size) has a specific control, and you set them by providing the axis name and a value.
How It Works
Variable fonts expose registered axes (standardized four-letter codes) and sometimes custom axes (defined by the font designer). You control these using the following syntax:
.custom-text {
font-variation-settings: 'wght' 650, 'wdth' 85;
}
Here, 'wght' controls weight (650 = semi-bold) and 'wdth' controls width (85 = slightly condensed).
Common Registered Axes
'wght'— Weight (100–900, like font-weight)'wdth'— Width (percentage, typically 75–125)'slnt'— Slant (angle in degrees)'opsz'— Optical size (point size)'ital'— Italics (0 or 1)
Real-World Example
.headline {
font-family: 'MyVariableFont', sans-serif;
font-variation-settings: 'wght' 800, 'wdth' 110, 'slnt' -10;
}
This creates a bold, expanded, slightly slanted headline—all from a single font file.
Important Note
While font-variation-settings gives you precise control, prefer higher-level properties like font-weight when possible for better accessibility and browser optimization. Use this property for axes that don't have dedicated CSS properties.
Key Takeaway: font-variation-settings lets you fine-tune variable font characteristics by directly setting axis values, giving you pixel-perfect control over typography within a single font file.