CSS font-synthesis-position Property
The font-synthesis-position property controls whether a browser may synthesize superscript and subscript glyphs when the selected font does not provide them.
Some fonts include specially designed characters for superscripts and subscripts. When these glyphs are unavailable, a browser may approximate their appearance by reducing and repositioning ordinary characters. The font-synthesis-position property allows authors to permit or prevent this synthetic positioning.
font-synthesis-position Syntax
The font-synthesis-position property accepts auto, none, or a CSS-wide keyword.
Basic Syntax
selector {
font-synthesis-position: auto;
}
Allow Synthetic Positioning
selector {
font-synthesis-position: auto;
}
Disable Synthetic Positioning
selector {
font-synthesis-position: none;
}
CSS-Wide Keywords
.example {
font-synthesis-position: inherit;
}
.example {
font-synthesis-position: initial;
}
.example {
font-synthesis-position: unset;
}
.example {
font-synthesis-position: revert;
}
.example {
font-synthesis-position: revert-layer;
}
The property controls whether synthetic positioning is permitted. It does not directly request superscript or subscript text.
Property Values
The property has two main values.
| Value | Description |
|---|---|
auto |
Allows the browser to synthesize superscript or subscript glyphs when necessary. |
none |
Prevents the browser from synthesizing superscript or subscript glyphs. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | All elements and text |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
The property is a longhand of font-synthesis. It can be controlled independently or through the shorthand's position keyword.
How It Works
Superscript and subscript text often requires characters that are smaller and positioned above or below the normal text baseline.
Genuine Positioned Glyphs
Some fonts contain specially designed superscript and subscript glyphs. These characters may have adjusted proportions and stroke weights to remain readable at smaller sizes.
Synthetic Positioned Glyphs
When the requested positioned glyphs are unavailable, a browser may approximate them using ordinary characters that are reduced and repositioned.
Allowing Synthesis
.superscript {
font-variant-position: super;
font-synthesis-position: auto;
}
Preventing Synthesis
.superscript {
font-variant-position: super;
font-synthesis-position: none;
}
Important Consideration
The browser's ability to use genuine or synthetic positioned glyphs depends on font support and the implementation of font-variant-position and font-synthesis-position.
The auto Value
The auto value permits the browser to synthesize positioned glyphs when suitable superscript or subscript glyphs are unavailable.
Basic Example
.superscript {
font-synthesis-position: auto;
}
Superscript Example
.superscript {
font-variant-position: super;
font-synthesis-position: auto;
}
Subscript Example
.subscript {
font-variant-position: sub;
font-synthesis-position: auto;
}
Default Behavior
Because auto is the initial value, browsers may synthesize positioned glyphs when other relevant CSS properties request them.
Important Consideration
The auto value permits synthesis but does not guarantee a visible change. The selected font may already provide genuine positioned glyphs.
The none Value
The none value prevents synthetic superscript and subscript glyph generation.
Basic Example
.superscript {
font-synthesis-position: none;
}
Use with font-variant-position
.superscript {
font-variant-position: super;
font-synthesis-position: none;
}
Subscript Example
.subscript {
font-variant-position: sub;
font-synthesis-position: none;
}
Preserving Font Design
Disabling synthesis can help prevent browsers from generating approximations that differ from the font designer's intended appearance.
Important Consideration
If the font lacks genuine superscript or subscript glyphs, disabling synthesis may leave the text without the requested typographic positioning. Test the result before using this setting for important content.
Superscript Text
Superscript text appears above the normal baseline and is commonly used for mathematical exponents, footnote references, and ordinal indicators.
CSS Superscript
.superscript {
font-variant-position: super;
font-synthesis-position: auto;
}
HTML Example
<p>x<span class="superscript">2</span></p>
Using the sup Element
<p>x<sup>2</sup></p>
The <sup> element provides semantic superscript markup and generally receives suitable default styling from the browser.
Important Consideration
The font-synthesis-position property does not replace the <sup> element. Use semantic HTML for mathematical exponents and other meaningful superscripts.
Subscript Text
Subscript text appears below the normal baseline and is commonly used in chemical formulas, mathematical notation, and scientific expressions.
CSS Subscript
.subscript {
font-variant-position: sub;
font-synthesis-position: auto;
}
HTML Example
<p>H<span class="subscript">2</span>O</p>
Using the sub Element
<p>H<sub>2</sub>O</p>
The <sub> element provides semantic subscript markup and is appropriate for chemical formulas and other meaningful subscripts.
Important Consideration
Use <sub> for meaningful subscript content. The CSS synthesis property only controls whether missing positioned glyphs may be approximated.
Using font-variant-position
The font-variant-position property requests superscript or subscript glyphs, while font-synthesis-position determines whether the browser may synthesize missing positioned glyphs.
Superscript
.superscript {
font-variant-position: super;
font-synthesis-position: auto;
}
Subscript
.subscript {
font-variant-position: sub;
font-synthesis-position: auto;
}
Disable Synthesis
.superscript {
font-variant-position: super;
font-synthesis-position: none;
}
Property Comparison
| Property | Purpose |
|---|---|
font-variant-position |
Requests normal, superscript, or subscript glyph positioning. |
font-synthesis-position |
Controls whether missing positioned glyphs may be synthesized. |
Important Consideration
The properties work together, but browser support for the newer synthesis control may be limited. Semantic HTML and conventional CSS provide more dependable fallback behavior.
The font-synthesis Shorthand
The font-synthesis shorthand controls multiple types of synthetic font styling, including weight, style, small capitals, and positioned glyphs.
Allow Position Synthesis
.text {
font-synthesis: position;
}
Allow Multiple Types
.text {
font-synthesis: weight style position;
}
Disable All Synthesis
.text {
font-synthesis: none;
}
Equivalent Longhand
.text {
font-synthesis-position: none;
}
The longhand affects only synthetic positioning. The shorthand can change several synthesis controls at once.
Shorthand Reset Behavior
.text {
font-synthesis-position: none;
font-synthesis: weight style position;
}
The later shorthand permits position synthesis again because it resets the constituent longhand properties.
Important Consideration
Use the longhand when only superscript and subscript synthesis needs to be controlled. Check compatibility before relying on the position keyword in the shorthand.
Genuine vs. Synthetic Glyphs
Genuine superscript and subscript glyphs are designed specifically for their typographic positions. Synthetic glyphs approximate these designs using ordinary characters.
Genuine Glyphs
A font may contain superscript and subscript glyphs with adjusted stroke weights, spacing, and proportions to improve readability.
Synthetic Glyphs
When genuine glyphs are missing, a browser may approximate them by reducing and repositioning ordinary glyphs.
Comparison
| Feature | Genuine Glyphs | Synthetic Glyphs |
|---|---|---|
| Source | Provided by the font | Generated by the browser |
| Design | Specially drawn for the position | Approximated from ordinary glyphs |
| Stroke weight | May be optically adjusted | May appear thinner after scaling |
| Control | Depends on available font features | Can be restricted by font synthesis controls |
Important Consideration
Genuine positioned glyphs generally provide more consistent typography. Synthetic positioning can be useful when a font lacks the necessary glyphs, but the visual result may differ.
Semantic HTML
HTML provides dedicated elements for meaningful superscript and subscript text.
Superscript with sup
<p>The area is measured in m<sup>2</sup>.</p>
Subscript with sub
<p>The chemical formula is CO<sub>2</sub>.</p>
Default Browser Styling
Browsers typically render <sup> and <sub> using smaller text positioned above or below the baseline.
CSS Styling
sup,
sub {
font-size: 0.75em;
}
Important Consideration
Use <sup> and <sub> for semantic meaning. The font-synthesis-position property controls font synthesis and does not replace these HTML elements or their accessibility benefits.
Inheritance
The font-synthesis-position property is inherited. Child elements use the parent's synthesis setting unless they specify another value.
Inherited Setting
.container {
font-synthesis-position: none;
}
<div class="container">
<p>H<sub>2</sub>O</p>
</div>
Override a Child
.container {
font-synthesis-position: none;
}
.container .allow-position {
font-synthesis-position: auto;
}
Explicit Inheritance
.child {
font-synthesis-position: inherit;
}
Reset to the Initial Value
.child {
font-synthesis-position: initial;
}
The initial value is auto.
Important Consideration
Inherited synthesis settings may affect descendants using different fonts. The visual result still depends on whether those fonts provide genuine positioned glyphs and whether the browser supports the feature.
font-synthesis-position Example
This example demonstrates how font-synthesis-position can be combined with font-variant-position to control superscript and subscript synthesis.
Because support for synthetic position controls is limited, the example also includes semantic HTML superscripts and subscripts as a reliable comparison.
HTML Example
<div class="font-position-demo">
<p class="demo-label">CSS superscript - synthesis allowed</p>
<p>x<span class="css-super">2</span> + y<span class="css-super">2</span></p>
<p class="demo-label">CSS subscript - synthesis allowed</p>
<p>H<span class="css-sub">2</span>O</p>
<p class="demo-label">Semantic HTML superscript</p>
<p>x<sup>2</sup> + y<sup>2</sup></p>
<p class="demo-label">Semantic HTML subscript</p>
<p>H<sub>2</sub>O</p>
</div>
CSS Example
.font-position-demo {
font-family: Georgia, serif;
font-size: 24px;
}
.font-position-demo p {
margin: 0 0 16px;
}
.font-position-demo .demo-label {
font: 600 13px/1.4 Arial, sans-serif;
}
.css-super {
font-variant-position: super;
font-synthesis-position: auto;
}
.css-sub {
font-variant-position: sub;
font-synthesis-position: auto;
}
CSS superscript - synthesis allowed
x2 + y2
CSS subscript - synthesis allowed
H2O
Semantic HTML superscript
x2 + y2
Semantic HTML subscript
H2O
In browsers that support the relevant font features, the CSS examples may use genuine or synthesized positioned glyphs. In browsers without support, the CSS examples may remain on the normal baseline.
The semantic HTML examples use the browser's established <sup> and <sub> rendering behavior and provide a more dependable solution for meaningful superscripts and subscripts.
Common Mistakes
The most common mistake is expecting font-synthesis-position to create superscript or subscript formatting by itself.
Using super as a Value
.superscript {
font-synthesis-position: super;
}
This declaration is invalid. Use font-variant-position: super to request superscript glyphs.
Using sub as a Value
.subscript {
font-synthesis-position: sub;
}
This declaration is invalid. Use font-variant-position: sub to request subscript glyphs.
Using a Length Value
.superscript {
font-synthesis-position: 5px;
}
The property does not accept lengths.
Using a Percentage
.subscript {
font-synthesis-position: 50%;
}
Percentages are not valid values.
Expecting the Property to Move Text
The property controls permission to synthesize positioned glyphs. It does not directly change an element's vertical position.
Assuming All Fonts Have Genuine Positioned Glyphs
Many fonts do not provide dedicated superscript and subscript glyphs for every character.
Disabling Synthesis Without Testing
When genuine positioned glyphs are unavailable, disabling synthesis may prevent the intended typographic appearance.
Ignoring Browser Support
The property is newer and may not be implemented consistently across browsers.
Replacing Semantic HTML
Do not replace meaningful <sup> and <sub> markup with CSS-only styling when the content requires semantic superscript or subscript meaning.
Important Considerations
Keep the following points in mind when using the font-synthesis-position property:
- Purpose: Controls synthetic superscript and subscript glyphs.
- Property type: Longhand of
font-synthesis. - Initial value:
auto. - Inheritance: The property is inherited.
- Applies to: All elements and text.
- auto: Permits synthetic positioned glyphs.
- none: Prevents synthetic positioned glyphs.
- Font selection: Genuine positioned glyphs may be used when available.
- Font synthesis: Browsers may approximate missing positioned glyphs.
- font-variant-position: Requests superscript or subscript glyphs.
- font-synthesis: Provides shorthand control through the
positionkeyword. - Shorthand reset: Later shorthand declarations can override the longhand.
- Semantic HTML: Use
<sup>and<sub>for meaningful positioned text. - Accessibility: Preserve semantic markup and readable character sizes.
- Font support: Not all fonts provide genuine superscript and subscript glyphs.
- Browser support: The property has limited or evolving compatibility.
- Fallbacks: Provide dependable markup and styling when browser support is unavailable.
Use font-synthesis-position when fine control over synthetic superscript and subscript glyphs is needed. For ordinary mathematical, chemical, and reference notation, semantic HTML remains the preferred foundation.
Browser Support
The CSS font-synthesis-position property has Limited availability compared with established font properties such as font-style and font-weight.
Support for synthetic superscript and subscript controls may vary across Chrome, Edge, Firefox, Safari, and their versions. Browsers that do not recognize the property ignore the declaration.
Basic Example
.superscript {
font-synthesis-position: none;
}
Feature Detection
@supports (font-synthesis-position: none) {
.superscript {
font-synthesis-position: none;
}
}
Progressive Enhancement
.superscript {
font-variant-position: super;
}
@supports (font-synthesis-position: none) {
.superscript {
font-synthesis-position: none;
}
}
Feature detection checks whether the browser recognizes the declaration. It does not guarantee that the selected font contains genuine positioned glyphs.
Fallback Recommendation
For meaningful superscripts and subscripts, use the HTML <sup> and <sub> elements. These provide more dependable behavior across browsers.
For current compatibility information, visit Can I Use? and search for font-synthesis-position.
Specifications
The font-synthesis-position property is defined in the CSS Fonts Module, which describes font synthesis controls and the handling of positioned glyphs.
CSS Fonts Module Level 4: font-synthesis-position
The CSS Fonts Module also defines the font-synthesis shorthand and related longhand properties.
For additional explanations and examples, see MDN Web Docs.
