Font-variant-position - CSS Property

font-variant-position

Summary of characteristics of the font-variant-position property

Quick description
Superscript or subscript of characters.
Status
Compatibility issues ⚠
Predefined values
normal | sub | super
Percentages
Not applicable.
Initial value
normal
Inherited by default
Yes.
Discrète: during an animation, the font-variant-position property passes from one value to another without transition.
Single: single value (no order).
W3C Module
CSS Fonts Module
 🡇  
 🡅  
Document status: WD (Working Draft)

Document status: REC (Recommendation)

Syntax diagram of font-variant-position.

Font-variant-position property - Syntax diagramSyntax diagram of the font-variant-position CSS property. See stylescss.free.fr for details. normal normal sub sub super superfont-variant-position:;font-variant-position:;
Syntax diagram of the font-variant-position property.
The links in the diagram provide more details about the values.
Download the diagram.

Description of the font-variant-position property.

The font-variant-position property allows subscript or superscript formatting.

It seems to overlap with the vertical-align property or with the HTML sub and sup tags, but the difference is that font-variant-position takes advantage of OTF font features, whereas the other solutions work by calculation. This means that font-variant-position can use different glyphs for superscripts or subscripts than the ones used for standard characters. These glyphs are provided by the font and are better suited for subscript or superscript formatting.

HTML tags sup et sub.
Good compatibility.
Changes the line spacing.
Reduces the font size.
Example: In a race, when you overtake the 2nd person, you are still only the 2nd.
vertical-align property.
Good compatibility.
Changes the line spacing.
Does not reduce the font size.
Example: In a race, when you overtake the 2nd, you are still the 2nd.
font-variant-position property.
Better aesthetics.
Not all characters (1) and depends on the font.
Reduces the size and possibly the shape of characters.
Example: In a race, when you overtake the 2nd person, you are still the 2nd.

(1) Fonts rarely provide superscript and subscript glyphs for all characters. Often it's only the numbers that come in superscript and subscript.

Below is a comparison result between the three methods.

HTML Tags sup et sub.
This first text contains superscripts and subscripts formatted with the HTML tags sup and sub.
The characters in superscript or subscript are not only shifted relative to the baseline, but they are also in a smaller size. The height of the first line has also been increased.
This is the normal behavior of the sup and sub tags.
vertical-align property.
This second text contains superscripts and subscripts formatted with the vertical-align property.
We can see that the font size hasn’t been changed. The line spacing is increased.
font-variant-position property.
Finally, this text contains superscripts and subscripts formatted with the property font-variant-position.
The size of the superscript or subscript characters has been reduced, but their shape may also be adjusted (depending on the font). There is no need to change the line spacing. From a typographic point of view, this result is the best of the three, but unfortunately, it is very dependent on the font chosen and the browser used.

⚠ This example won't work on all browsers: the property font-variant-position is still not well recognized. Needs testing on Firefox  .

Here is a CSS code that allows you to get proper formatting on all browsers, while making the most of each one's capabilities. It uses the @supports directive to test browser compatibility.

@supports not (font-variant-position:super) { <selector> { vertical-align: top; font-size: 0.75em; } } @supports (font-variant-position:super) { <selector> { font-variant-position:super; } }

See also the shorthand property font-variant, the font-feature-settings property for a general overview of OTF font capabilities, and finally, the font-synthesis-position property to enable or disable the calculation of superscripts and subscripts when the font does not offer these variants.

Values for font-variant-position.

  • font-variant-position: normal;

    Default value. The characters are on the baseline.

  • font-variant-position: super;

    superscript writing.

    The value super is equivalent to font-feature-settings:'sups'.

    Example for font-variant-position:super
    This is a simulation.

  • font-variant-position: sub;

    Subscript writing.

    The sub value is equivalent to font-feature-settings:'subs'.

    Example for font-variant-position:sub
    This is a simulation

  • font-variant-position: initial; (normal) font-variant-position: inherit; font-variant-position: revert; font-variant-position: revert-layer; font-variant-position: revert-rule; font-variant-position: unset;

    Links to the presentation of these different values: initial, inherit, revert, revert-layer, revert-rule, unset.

Animation of the font-variant-position property.

Here's a little visual (without any big claim) that uses the ability to animate the font-variant-position property. For now, it only works on Firefox.

Sometimes we hesitate between exponent and indice.

Simulator.

The simulator applies the property font-variant-position to the parts of text in blue. These are enclosed in span tags.

font-variant-position :
Chemical formula of sugar: C12H220

Area of a circle: πd2/4

Browsers compatibility with font-variant-position.

The font-variant-position property still has compatibility issues on many browsers.

Column 1
Support for the font-variant-position property allowing subscript or superscript of text.
1
font-variant-position
property
Estimated overall support.
20%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

KaiOS Browser

Opéra Mobile

Opéra

Safari

Safari sur IOS

Firefox pour Androïd

Samsung Internet

Chrome

Edge

Firefox

Androïd Brower

Chrome pour Androïd

Baidu Browser

QQ Browser

UC Browser pour Androïd

Opéra mini

Historic of the font-variant-position property.

  • CSS Fonts Module Level 3

    This specification concerns fonts. A font contains the visual representation of characters. In its simplest form, it is just a matter of associating character codes with their shapes.
    Within a typeface family, the shapes are defined but can vary in stroke thickness, slant, width, etc. The CSS properties font-... allow choosing the final appearance of the characters.
    Fonts can be located on the user's computer or downloaded.

    Regarding font-variant-position:
    Level 3 of this specification introduces the font-variant-position property for the first time.
    WD
    July 21, 1997
    Working Draft.
    CR
    October 03, 2013
    Candidate Recommendation.
    PR
    August 14, 2018
    Proposed for recommendation.
    REC
    September 20, 2018
    Recommendation .
  • CSS Fonts Module Level 4

    This level 4 of the specification on fonts reprises what is defined in level 3. It adds the possibility to define what happens when a font takes a long time to load or is missing. It also adds support for colored fonts and clarifies many points still poorly defined in level 3.

    Regarding font-variant-position:
    No change to the font-variant-position property.
    WD
    July 11, 2017
    Working Draft.
    CR
    PR
    REC
  • CSS Fonts Module Level 5

    WD
    June 29, 2021
    Working Draft.
    CR
    PR
    REC

See alse about fonts.

Everything related to fonts is grouped in the CSS Fonts Module specification: typography, using the features of modern font formats, downloading fonts, and so on.

Properties:

font
Langue française
Shorthand to set most properties for fonts.
✗
font-effect
Langue française
Allows you to apply some effects to the text: relief, border...
font-family
Selects a font from those that are available or downloaded.
⚠
font-feature-settings
Langue française
Permet d’exploiter les fonctionnalités spécifiques des polices de caractères OTF, WOFF, etc.
font-kerning
Adjusting the kerning between characters.
⚠
font-language-override
Langue française
Defines the language to be considered when choosing characters.
⚠
font-optical-sizing
Langue française
Optimizes the shape of characters based on their size.
font-palette
Langue française
Defines the color palette that can be used for colored fonts.
font-size
Adjusts the font size, which also impacts units like em, ex, etc.
font-size-adjust
Langue française
Definition of the aspect factor of the font.
✗
font-smooth
Langue française
Defines whether and which smoothing algorithm should be used.
font-stretch
Langue française
Changes the stretching or compression of characters.
font-style
Langue française
Selects the italic or oblique font styles.
font-synthesis
Allows or disallows calculation of missing styles in the typeface.
⚠
font-synthesis-position
Langue française
Whether or not allows the browser to synthesize characters in superscript or subscript.
font-synthesis-small-caps
Langue française
Whether or not allows the browser to calculate the glyphs of characters in small caps.
font-synthesis-style
Langue française
Defines whether the browser is allowed to synthesize italic forms of characters.
font-synthesis-weight
Langue française
Defines whether or not the browser can calculate the bold glyph.
font-variant
Shorthand to define advanced typographic attributes: ligatures, character substitution, etc.
font-variant-alternates
Defines character substitution (OTF, WOFF fonts).
font-variant-caps
Applies character capitalization.
font-variant-east-asian
Typography specific to Chinese or Japanese characters.
⚠
font-variant-emoji
Choose between an emoji or text presentation.
font-variant-ligatures
Enables or disables character ligation.
font-variant-numeric
Defines how evolved numbers are displayed: fractions, numbers, etc.
Font-variant-position
Superscript or subscript of characters.
font-variation-settings
Provides access to the stylistic possibilities of OTF fonts.
font-weight
Selects a weight for the characters.
font-width
Langue française
Synonymous with font-stretch (character width/enlargement).

Functions:

⚠
palette-mix()
Langue française
Establish the mixture of two color palettes from two different typefaces.

At-rules:

@font-face
Langue française
Defines all settings for a downloadable font.
⚠
@font-feature-values
Langue française
Defines the typographic variations to use.
@font-palette-values
Langue française
Defines a color palette that can then be applied to a font.

Descriptors :

ascent-override
Langue française
Descriptor for @font-face. Sets the height of the characters above the baseline.
descent-override
Langue française
Descriptor for @font-face. Sets the height of the characters below the baseline.
⚠
font-display
Langue française
Descriptor for @font-face. Determines how the browser behaves when faced with fonts that take a long time to load.
line-gap-override
Langue française
Descriptor for @font-face. Sets the line spacing of the font.
src
Langue française
Defines the source of a font file to download, or an image to display.
unicode-range
Langue française
Descriptor for @font-face. Defines the range of character codes to be downloaded into a font.