Font-variant-position - CSS Property
Summary of characteristics of the font-variant-position property
normal | sub | supernormalDiscrète: during an animation, the font-variant-position property passes from one value to another without transition.Single: single value (no order).Syntax diagram of font-variant-position.
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.
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.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.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.
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.vertical-align property.We can see that the font size hasn’t been changed. The line spacing is increased.
font-variant-position 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 .
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
superis equivalent tofont-feature-settings:'sups'.
This is a simulation. - font-variant-position: sub;
Subscript writing.
The
subvalue is equivalent tofont-feature-settings:'subs'.
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.
Simulator.
The simulator applies the property font-variant-position to the parts of text in blue. These are enclosed in span tags.
Area of a circle: πd2/4
Browsers compatibility with font-variant-position.
The font-variant-position property still has compatibility issues on many browsers.
font-variant-position property allowing subscript or superscript of text.font-variant-positionproperty
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 propertiesfont-...allow choosing the final appearance of the characters.
Fonts can be located on the user's computer or downloaded.Regardingfont-variant-position:
Level 3 of this specification introduces thefont-variant-positionproperty for the first time.July 21, 1997Working Draft.October 03, 2013Candidate Recommendation.August 14, 2018Proposed for recommendation.September 20, 2018Recommendation . -
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.
Regardingfont-variant-position:
No change to thefont-variant-positionproperty.July 11, 2017Working Draft. -
CSS Fonts Module Level 5
June 29, 2021Working Draft.
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:






em, ex, etc.








Functions:

At-rules:



Descriptors :

@font-face. Sets the height of the characters above the baseline.

@font-face. Sets the height of the characters below the baseline.

@font-face. Determines how the browser behaves when faced with fonts that take a long time to load.

@font-face. Sets the line spacing of the font.

@font-face. Defines the range of character codes to be downloaded into a font.


