Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

font-variation-settings — variable font axes

The font-variation-settings property provides low-level control of variable font axes through tags paired with numeric values.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

font-variation-settings: normal | [ <opentype-tag> <number> ]#;

font-variation-settings accepts normal or comma-separated tag–number pairs. It is inherited; the initial normal means no changes caused by this property.

A tag is a case-sensitive string of exactly four ASCII characters within U+0020–U+007E. Numbers may be negative or fractional. Unsupported axes are ignored; values outside an axis range are clamped to the nearest supported value.

Prefer font-weight for wght, font-style for slnt/ital, and font-optical-sizing for opsz. For wdth, use font-width, the CSS Fonts Level 4 name. For compatibility, declare font-stretch with the same value before font-width: browsers that support only font-stretch ignore font-width. The low-level list is replaced as a whole, not merged axis by axis.

The example checks computed values without an external font. A visible change requires a font supporting the specified axis.

Examples

<!doctype html>
<meta charset="utf-8">
<title>font-variation-settings</title>
<style>
  #sample { font-variation-settings: "wght" 650; }
  #sample span { font-variation-settings: normal; }
</style>
<p id="sample">Axis setting <span>Reset</span></p>
<pre id="result"></pre>
<script>
  const sample = document.querySelector('#sample');
  const child = sample.querySelector('span');
  document.querySelector('#result').textContent = [
    getComputedStyle(sample).fontVariationSettings,
    getComputedStyle(child).fontVariationSettings
  ].join('\n');
</script>

Result

"wght" 650
normal

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources