CSS font-feature-settings Property
The font-feature-settings property provides low-level control over OpenType font features, including ligatures, alternate glyphs, numeral styles, and other typographic capabilities.
Each feature is identified by a four-character OpenType tag. The property allows developers to enable, disable, or adjust features supported by the selected font. For commonly used features, higher-level CSS properties such as font-variant-ligatures and font-variant-numeric are generally preferable.
font-feature-settings Syntax
The font-feature-settings property accepts the keyword normal or a comma-separated list of OpenType feature tags with optional values.
Basic Syntax
selector {
font-feature-settings: "liga";
}
The "liga" tag requests standard ligatures. Omitting the value is equivalent to enabling the feature with a value of 1.
Enable a Feature
selector {
font-feature-settings: "liga" on;
}
Disable a Feature
selector {
font-feature-settings: "liga" off;
}
Numeric Values
selector {
font-feature-settings: "liga" 1;
}
selector {
font-feature-settings: "liga" 0;
}
Multiple Features
selector {
font-feature-settings: "liga" 1, "kern" 1, "onum" 1;
}
Default Value
selector {
font-feature-settings: normal;
}
The normal keyword allows the browser to use its normal font feature selection behavior. It does not mean that every OpenType feature is disabled.
CSS-Wide Keywords
.example {
font-feature-settings: inherit;
}
.example {
font-feature-settings: initial;
}
.example {
font-feature-settings: unset;
}
.example {
font-feature-settings: revert;
}
.example {
font-feature-settings: revert-layer;
}
CSS-wide keywords must be used alone and cannot be combined with individual OpenType feature tags.
Property Values
The property accepts OpenType feature tags and values that determine whether a feature is enabled or disabled.
| Value | Description |
|---|---|
normal |
Uses the browser's normal OpenType feature selection behavior. |
"tag" |
Enables the specified OpenType feature with a value of 1. |
"tag" on |
Enables the specified feature. |
"tag" off |
Disables the specified feature. |
"tag" 1 |
Enables the feature using the numeric value 1. |
"tag" 0 |
Disables the feature using the numeric value 0. |
"tag" n |
Uses a non-negative integer value, which may select an alternate when the feature supports multiple choices. |
CSS-Wide Values
| Value | Description |
|---|---|
inherit |
Uses the computed value from the parent element. |
initial |
Restores the initial value, normal. |
unset |
Uses the inherited value because the property is inherited. |
revert |
Reverts the property according to CSS cascade origins. |
revert-layer |
Reverts the property according to CSS cascade layers. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | normal |
| Inherited | Yes |
| Applies to | All elements and text |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
The feature tag must contain exactly four ASCII characters and is written inside quotation marks. Numeric feature values must be non-negative integers.
How It Works
OpenType fonts can contain optional features that change how characters are displayed. The font-feature-settings property requests specific features from the font.
Step 1: Select a Font
.example {
font-family: Georgia, serif;
}
Step 2: Enable a Feature
.example {
font-family: Georgia, serif;
font-feature-settings: "liga" 1;
}
The browser requests standard ligatures from the selected font.
Step 3: Use Available Glyphs
If the font supports the requested feature for the relevant characters, the browser can use the corresponding glyph substitutions or positioning adjustments.
Step 4: Handle Unsupported Features
If the font does not provide the requested feature, the browser generally continues rendering the text without that feature.
Important Consideration
The property does not create new glyphs or add capabilities to a font. Its visual effect depends on the features built into the selected font and the text being displayed.
OpenType Feature Tags
OpenType features are identified by four-character tags. Each tag represents a particular typographic capability.
| Tag | Feature | Description |
|---|---|---|
"liga" |
Standard ligatures | Enables common character combinations such as fi and fl. |
"dlig" |
Discretionary ligatures | Enables optional decorative ligatures. |
"hlig" |
Historical ligatures | Enables historical ligature forms. |
"kern" |
Kerning | Adjusts spacing between certain glyph pairs. |
"smcp" |
Small capitals | Substitutes lowercase characters with small capital glyphs. |
"c2sc" |
Capitals to small capitals | Substitutes uppercase characters with small capital glyphs. |
"onum" |
Oldstyle figures | Uses numerals with varying heights and alignments. |
"lnum" |
Lining figures | Uses numerals designed to align with uppercase letter heights. |
"tnum" |
Tabular figures | Uses numerals with equal advance widths. |
"pnum" |
Proportional figures | Uses numerals with varying advance widths. |
"frac" |
Fractions | Enables fraction formatting when supported. |
"zero" |
Slashed zero | Uses an alternate zero glyph to distinguish it from the letter O. |
"salt" |
Stylistic alternates | Selects alternate glyph designs. |
"ss01" |
Stylistic set 1 | Enables the first font-defined stylistic set. |
"swsh" |
Swash | Enables decorative swash glyphs. |
"calt" |
Contextual alternates | Changes glyph forms according to surrounding characters. |
Example with Multiple Tags
.typography {
font-feature-settings: "liga" 1, "kern" 1, "onum" 1;
}
This declaration requests standard ligatures, kerning, and oldstyle numerals.
Important Consideration
OpenType feature tags are case-sensitive. Use the correct four-character tag, typically written in lowercase.
Not every font supports every tag. Consult the font documentation or inspect the font's available features before relying on a particular result.
Controlling Ligatures
Ligatures combine two or more characters into a specially designed glyph or glyph sequence. They can improve the appearance of certain letter combinations.
Enable Standard Ligatures
.ligatures-on {
font-feature-settings: "liga" 1;
}
Disable Standard Ligatures
.ligatures-off {
font-feature-settings: "liga" 0;
}
Enable Discretionary Ligatures
.decorative-heading {
font-feature-settings: "dlig" 1;
}
Enable Historical Ligatures
.historical-text {
font-feature-settings: "hlig" 1;
}
Common Ligature Combinations
Common examples include the letter combinations fi, fl, ffi, and ffl. Whether these combinations use ligatures depends on the font.
Important Consideration
Standard ligatures may already be enabled by default. Use font-variant-ligatures when possible because it provides a more descriptive way to control common ligature behavior.
Numeric Font Features
OpenType fonts may provide alternative numeral designs for different types of content.
Oldstyle Numerals
.oldstyle-numbers {
font-feature-settings: "onum" 1;
}
Oldstyle numerals can have varying heights and may extend below the baseline, depending on the font.
Lining Numerals
.lining-numbers {
font-feature-settings: "lnum" 1;
}
Lining numerals generally align with the height of uppercase letters.
Tabular Numerals
.tabular-numbers {
font-feature-settings: "tnum" 1;
}
Tabular numerals have equal advance widths, making them useful for aligned numeric columns.
Proportional Numerals
.proportional-numbers {
font-feature-settings: "pnum" 1;
}
Proportional numerals use widths appropriate to individual digits.
Fractions
.fractions {
font-feature-settings: "frac" 1;
}
Fonts supporting the fraction feature may display appropriate digit sequences using fraction glyphs and positioning.
Slashed Zero
.code-numbers {
font-feature-settings: "zero" 1;
}
A slashed zero can help distinguish the digit 0 from the uppercase letter O.
Important Consideration
For common numeric styles, prefer font-variant-numeric. It provides descriptive keywords such as tabular-nums, oldstyle-nums, and slashed-zero.
Alternate Glyphs
Some OpenType fonts include alternate glyph designs that can change the appearance of letters without changing the underlying text.
Stylistic Alternates
.alternate-text {
font-feature-settings: "salt" 1;
}
Stylistic Set 1
.stylistic-set-one {
font-feature-settings: "ss01" 1;
}
Stylistic Set 2
.stylistic-set-two {
font-feature-settings: "ss02" 1;
}
Swash Characters
.decorative-title {
font-feature-settings: "swsh" 1;
}
Contextual Alternates
.contextual-text {
font-feature-settings: "calt" 1;
}
Selecting a Numeric Alternate
.alternate-choice {
font-feature-settings: "salt" 2;
}
For features that support indexed alternate selections, an integer greater than 1 may request a particular alternate. The available choices depend on the font.
Important Consideration
Stylistic sets and alternate glyphs are font-specific. The same tag may produce very different visual results in different typefaces.
Small Capital Letters
Some fonts contain specially designed small capital glyphs. These glyphs can provide better typography than automatically scaled uppercase letters.
Small Capitals
.small-caps {
font-feature-settings: "smcp" 1;
}
Capitals to Small Capitals
.all-small-caps {
font-feature-settings: "smcp" 1, "c2sc" 1;
}
Using font-variant-caps
.small-caps {
font-variant-caps: small-caps;
}
.all-small-caps {
font-variant-caps: all-small-caps;
}
The higher-level font-variant-caps property is generally preferable for small capital styling because it expresses the intended typographic result directly.
Important Consideration
If a font lacks true small capital glyphs, the browser may use synthesized small capitals for some higher-level font variant settings. Low-level feature requests do not guarantee that the requested glyphs exist.
Combining Multiple Features
Multiple OpenType features can be requested in one declaration by separating them with commas.
Ligatures and Kerning
.body-text {
font-feature-settings: "liga" 1, "kern" 1;
}
Tabular and Lining Numerals
.data-table {
font-feature-settings: "tnum" 1, "lnum" 1;
}
Oldstyle Numerals and Ligatures
.article-text {
font-feature-settings: "onum" 1, "liga" 1;
}
Disable One Feature and Enable Another
.custom-text {
font-feature-settings: "liga" 0, "kern" 1;
}
Stylistic Set and Swashes
.display-heading {
font-feature-settings: "ss01" 1, "swsh" 1;
}
Important Consideration
Each declaration provides a complete feature list. A later font-feature-settings declaration replaces an earlier declaration rather than adding its features.
If the same feature tag appears more than once in a single list, the last occurrence determines the requested value for that feature.
Relationship with font-variant
The font-feature-settings property provides low-level control over OpenType features. Higher-level font properties offer more descriptive ways to request many of the same typographic behaviors.
Low-Level Ligature Control
.example {
font-feature-settings: "liga" 0;
}
Higher-Level Ligature Control
.example {
font-variant-ligatures: no-common-ligatures;
}
Low-Level Numeric Control
.numbers {
font-feature-settings: "tnum" 1;
}
Higher-Level Numeric Control
.numbers {
font-variant-numeric: tabular-nums;
}
Low-Level Small Caps
.heading {
font-feature-settings: "smcp" 1;
}
Higher-Level Small Caps
.heading {
font-variant-caps: small-caps;
}
Feature Precedence
When low-level font-feature-settings values conflict with higher-level font variant settings, the low-level feature settings generally take precedence for the specified OpenType features.
Important Consideration
Use higher-level properties for standard typography requirements. Reserve font-feature-settings for specialized OpenType features or precise control that cannot be expressed through the higher-level properties.
Font Feature Availability
The visual effect of font-feature-settings depends on whether the selected font contains the requested OpenType feature.
Feature Supported by the Font
.example {
font-family: "Example OpenType Font", serif;
font-feature-settings: "onum" 1;
}
If the selected font provides oldstyle numerals, the browser can use them.
Feature Not Supported
.example {
font-family: Arial, sans-serif;
font-feature-settings: "ss09" 1;
}
If the selected font does not contain stylistic set 9, the requested feature has no corresponding glyph substitution.
Different Fonts, Different Results
Two fonts may support the same OpenType tag but provide different glyph designs. Other fonts may omit the feature entirely.
Font Loading
Custom fonts can be loaded using @font-face. The font files must contain the relevant OpenType feature data for the requested settings to affect rendering.
Important Consideration
CSS feature detection can confirm that a browser recognizes the property, but it cannot guarantee that a specific font contains a particular OpenType feature.
font-feature-settings Example
This example demonstrates how OpenType features can affect text. It compares normal font rendering with explicitly enabled and disabled ligatures, and shows a numeric formatting example.
The exact differences depend on the selected font and its available OpenType features.
HTML Example
<div class="feature-demo">
<p class="feature-label">Default ligatures</p>
<p class="feature-default">office affinity efficient</p>
<p class="feature-label">Ligatures disabled</p>
<p class="feature-no-liga">office affinity efficient</p>
<p class="feature-label">Ligatures enabled</p>
<p class="feature-liga">office affinity efficient</p>
<p class="feature-label">Tabular numerals</p>
<p class="feature-numbers">1234567890</p>
</div>
CSS Example
.feature-demo {
font-family: Georgia, serif;
}
.feature-demo p {
margin: 0 0 12px;
}
.feature-label {
font: 600 13px/1.4 Arial, sans-serif;
}
.feature-default {
font-size: 24px;
font-feature-settings: normal;
}
.feature-no-liga {
font-size: 24px;
font-feature-settings: "liga" 0;
}
.feature-liga {
font-size: 24px;
font-feature-settings: "liga" 1;
}
.feature-numbers {
font-size: 24px;
font-feature-settings: "tnum" 1, "lnum" 1;
}
Default ligatures
office affinity efficient
Ligatures disabled
office affinity efficient
Ligatures enabled
office affinity efficient
Tabular numerals
1234567890
The ligature examples request different rendering behavior for common character combinations. When the selected font supports standard ligatures, the enabled and disabled examples may display differently.
The numeric example requests lining and tabular figures. A font that supports those features can use numeral glyphs designed for consistent alignment.
Common Mistakes
Incorrect OpenType tags, unsupported font features, and misunderstandings about feature precedence can lead to unexpected results.
Using an Invalid Feature Tag
.example {
font-feature-settings: "ligatures" 1;
}
This declaration is invalid because an OpenType feature tag must contain exactly four ASCII characters.
Forgetting Quotation Marks
.example {
font-feature-settings: liga 1;
}
The feature tag must be written as a quoted string.
Using an Unsupported Feature
.example {
font-feature-settings: "ss15" 1;
}
The declaration can be syntactically valid even if the selected font does not provide stylistic set 15.
Expecting normal to Disable All Features
.example {
font-feature-settings: normal;
}
The normal keyword restores normal feature selection behavior. It does not disable all ligatures, kerning, or other default font features.
Using Multiple Declarations to Combine Features
.example {
font-feature-settings: "liga" 1;
font-feature-settings: "onum" 1;
}
The second declaration replaces the first. To request both features, combine them in one declaration.
Correct Combined Declaration
.example {
font-feature-settings: "liga" 1, "onum" 1;
}
Using a Negative Feature Value
.example {
font-feature-settings: "salt" -1;
}
Numeric feature values must be non-negative integers.
Using Low-Level Features Unnecessarily
For common features such as tabular numerals or small capitals, higher-level font-variant properties are generally easier to understand and maintain.
Important Considerations
Keep the following points in mind when using the font-feature-settings property:
- Purpose: Provides low-level control over OpenType font features.
- Initial value:
normal. - Inheritance: The property is inherited.
- Applies to: All elements and text.
- Feature tags: Must contain exactly four ASCII characters.
- Quotation marks: OpenType feature tags must be quoted.
- Case sensitivity: Feature tags are case-sensitive.
- Default feature value: A tag without a value is equivalent to a value of
1. - Enable features: Use
onor1. - Disable features: Use
offor0. - Numeric values: Non-negative integers can be used for features that support alternate selections.
- Multiple features: Separate feature settings with commas.
- Duplicate tags: The last occurrence of a repeated feature tag determines its requested value.
- Ligatures: Standard, discretionary, and historical ligatures can be controlled when supported.
- Numerals: OpenType features can request oldstyle, lining, tabular, and proportional figures.
- Alternate glyphs: Stylistic sets and swashes depend on the font.
- Small capitals: Can be requested through OpenType features when suitable glyphs exist.
- Font availability: The selected font must support a feature for it to affect rendering.
- Higher-level properties: Prefer
font-variantand related properties for common typography requirements. - Feature precedence: Explicit low-level feature settings can override corresponding higher-level settings.
- Shorthand reset: The
fontshorthand resetsfont-feature-settingsto its initial value. - Accessibility: Avoid decorative feature combinations that reduce character recognition or readability.
- Browser support: The property is widely supported in modern browsers, but font feature availability varies.
Use font-feature-settings when precise OpenType control is necessary. For ordinary font styling, higher-level CSS typography properties are usually clearer and more maintainable.
Browser Support
The CSS font-feature-settings property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.
Support for the CSS property does not guarantee that every OpenType feature is available. The actual result depends on the selected font, its supported features, and the browser's text shaping behavior.
Supported Example
.example {
font-feature-settings: "liga" 1, "kern" 1;
}
Feature Detection
@supports (font-feature-settings: "liga" 1) {
.example {
font-feature-settings: "liga" 1;
}
}
The @supports rule checks whether the browser recognizes the declaration. It does not verify that the selected font contains the requested feature.
Compatibility Considerations
Test specialized OpenType features with the actual fonts used on the website. Custom fonts may offer more predictable results than relying on system fonts with different feature sets.
For current compatibility information, visit Can I Use? and search for font-feature-settings.
Specifications
The font-feature-settings property is defined in the CSS Fonts Module, which describes OpenType font feature control and its relationship with higher-level typography properties.
CSS Fonts Module Level 4: font-feature-settings Property
Earlier specifications establish the syntax and behavior of the property.
CSS Fonts Module Level 3: font-feature-settings Property
OpenType feature tags and their definitions are maintained in the OpenType specification.
For additional explanations and examples, see MDN Web Docs.
