font-feature-settings
The font-feature-settings CSS property controls advanced typographic features in OpenType fonts.
Try it
Syntax
/* Use the default settings */
font-feature-settings: normal;
/* Set values for OpenType feature tags */
font-feature-settings: "smcp";
font-feature-settings: "smcp" on;
font-feature-settings: "swsh" 2;
font-feature-settings:
"smcp",
"swsh" 2;
/* Global values */
font-feature-settings: inherit;
font-feature-settings: initial;
font-feature-settings: revert;
font-feature-settings: revert-layer;
font-feature-settings: unset;
Whenever possible, Web authors should instead use the font-variant shorthand property or an associated longhand property such as font-variant-ligatures, font-variant-caps, font-variant-east-asian, font-variant-alternates, font-variant-numeric or font-variant-position.
These lead to more effective, predictable, understandable results than font-feature-settings, which is a low-level feature designed to handle special cases where no other way exists to enable or access an OpenType font feature. In particular, font-feature-settings shouldn't be used to enable small caps.
Values
This property is specified as either the keyword normal or as a comma-separated list of <feature-tag-value> values. When rendering text, the list of OpenType <feature-tag-value> values are passed to the text layout engine to enable or disable font features.
normal-
Indicates that text is laid out using default font settings. This is the default value.
<feature-tag-value>-
Represents a space-separated tuple consisting of a tag name and an optional value.
The tag name is always a
<string>of four ASCII characters. If the tag name has more or fewer characters or if it contains characters outside theU+20–U+7Ecode point range, the descriptor is invalid.The optional value can be a positive integer or the keyword
onoroff. The keywordsonandoffare synonyms for the values1and0, respectively. If no value is set, the default is1. For non-boolean OpenType features (e.g., stylistic alternates), the value implies a particular glyph to be selected; for boolean features, the value turns the feature on or off.
Formal definition
| Initial value | normal |
|---|---|
| Applies to | all elements and text. It also applies to ::first-letter and ::first-line. |
| Inherited | yes |
| Computed value | as specified |
| Animation type | discrete |
Formal syntax
Examples
Enabling various font features
/* use small-cap alternate glyphs */
.smallcaps {
font-feature-settings: "smcp" on;
}
/* convert both upper and lowercase to small caps (affects punctuation also) */
.allsmallcaps {
font-feature-settings: "c2sc", "smcp";
}
/* use zeros with a slash through them to differentiate from "O" */
.nicezero {
font-feature-settings: "zero";
}
/* enable historical forms */
.hist {
font-feature-settings: "hist";
}
/* disable common ligatures, usually on by default */
.noligs {
font-feature-settings: "liga" 0;
}
/* enable tabular (monospaced) figures */
td.tabular {
font-feature-settings: "tnum";
}
/* enable automatic fractions */
.fractions {
font-feature-settings: "frac";
}
/* use the second available swash character */
.swash {
font-feature-settings: "swsh" 2;
}
/* enable stylistic set 7 */
.fancystyle {
font-family: Gabriola;
font-feature-settings: "ss07";
}
Specifications
| Specification |
|---|
| CSS Fonts Module Level 4 # font-feature-settings-prop |
Browser compatibility
| desktop | mobile | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
font-feature-settings | |||||||||||
normal | |||||||||||