MDN self-hosted library · e01.org

CSSFontFeatureValuesRule: characterVariant property

CSSOM

Open notebook · 2 cells web-api-instance-property upstream source

CSSOM

The read-only characterVariant property of the CSSFontFeatureValuesRule interface contains a CSSFontFeatureValuesMap object representing the user-defined-ident and feature index for a variable font which supports character-variant().

Value

A CSSFontFeatureValuesMap object.

Although the characterVariant property itself is read-only in the sense that you can't replace the CSSFontFeatureValuesMap object, you can still assign to the characterVariant property directly. You can also modify the values of the characterVariant using the CSSFontFeatureValuesMap instance methods.

Examples

Basic usage

CSS

@font-feature-values "MonteCarlo" {
  @character-variant {
    my-character-variant: 1;
  }
}

JavaScript

// look for the first stylesheet and the first cssRule in that sheet
const myRule = document.styleSheets[0].cssRules[0];
// check
if (
  myRule instanceof CSSFontFeatureValuesRule &&
  myRule.characterVariant.size
) {
  // do something with the characterVariant
}

Specifications

Browser compatibility

See also

  • @character-variant
  • character-variant() functional notation
  • CSSFontFeatureValuesMap