font-variant-position property is used to enable typographic subscript and superscript glyphs.
One of the advanced features of OpenType typefaces is support for professionally designed subscript and superscript glyphs. Professionally designed subscript and superscript glyphs are designed to be visually compatible with the full-size figures in terms of weight and proportions. These glyphs are designed within the same em-box as default glyphs and are intended to be laid out on the same baseline as the default glyphs, with no resizing or repositioning of the baseline.
font-variant-position property allows us to take advantage of these proper, true-drawn subscripts and superscripts (also known as "inferiors" and "superiors").
These subscript and superscript glyphs are a perfect match for the
sup elements. Without the proper glyphs, the user agent needs to take a normal glyph, and resize it and reposition its baseline. This usually has less than optimal results. The glyph often looks slightly unproportional, and its repositioning can affect the line height. Properly designed glyphs will overcome these issues.
Subscript/superscript support varies by typeface. Some typefaces have only basic support for numerals, while others contain subscript and superscript glyphs for a full set of letters, numerals, and punctuation. If a variant glyph isn't available for all characters in the run, the user agent will simulate glyphs for all characters (just as it would have done if this feature wasn't applied or available). This prevents having a mixture of proper variant glyphs and synthesized ones that don't align correctly.
The syntax of the
font-variant-position property is:
These values are explained in more detail below.
- Specifies that neither subscript variants nor superscript variants are enabled.
- Enables subscript variants (OpenType feature:
- Enables superscript variants (OpenType feature:
In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:
- Represents the value specified as the property's initial value.
- Represents the computed value of the property on the element's parent.
- This value acts as either
initial, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.
- Initial Value
- Applies To
- All elements
This example uses the
@supports at-rule to apply styles only if the user agent supports the
In cases where the user agent doesn't support the
font-variant-position property, it will use its own default styles for the
sup elements, which might look like this:
- CSS Fonts Module Level 3 (W3C Candidate Recommendation 3 October 2013)
For maximum browser compatibility many web developers add browser-specific properties by using extensions such as
-webkit- for Safari, Google Chrome, and Opera (newer versions),
-ms- for Internet Explorer,
-moz- for Firefox,
-o- for older versions of Opera etc. As with any CSS property, if a browser doesn't support a proprietary extension, it will simply ignore it.
This practice is not recommended by the W3C, however in many cases, the only way you can test a property is to include the CSS extension that is compatible with your browser.
The major browser manufacturers generally strive to adhere to the W3C specifications, and when they support a non-prefixed property, they typically remove the prefixed version. Also, W3C advises vendors to remove their prefixes for properties that reach Candidate Recommendation status.
Many developers use Autoprefixer, which is a postprocessor for CSS. Autoprefixer automatically adds vendor prefixes to your CSS so that you don't need to. It also removes old, unnecessary prefixes from your CSS.
You can also use Autoprefixer with preprocessors such as Less and Sass.