font-variant-caps

CSS font-variant-caps Property

In CSS1 and CSS2, it was the font-variant property that specified small caps. But in CSS3, this property has become shorthand for CSS3 properties like font-variant-caps property. This property allows to select alternate glyphs for small, petite capitals and titling including many useful values like:

  • normal

  • small-caps

  • all-small-caps

  • petite-caps

  • all-petite-caps

  • unicase

  • titling-caps

When a given font involves capital letter glyphs that are of different size, the font-variant-caps property selects the most suitable ones. If small capital glyphs are not available they are rendered using uppercase glyphs.

The font-variant-caps property takes into account language-specific case mapping rules (e.g. in german (de), the ß may become ẞ (U+1E9E) in uppercase).

类目类目
Initial Valuenormal
Applies toAll elements. It also applies to ::first-letter and ::first-line.
InheritedYes.
AnimatableNo.
VersionCSS3
DOM Syntaxobject.style.fontVariantCaps = “petite-caps”;

Syntax

Syntax

font-variant-caps: normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps;

Example of the font-variant-caps property:

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document </title>
    <style>
      .all-small-caps {
        font-variant-caps: all-small-caps;
        font-style: italic;
      }
      .small-caps {
        font-variant-caps: small-caps;
        font-style: italic;
      }
      .normal {
        font-variant-caps: normal;
        font-style: italic;
      }
    </style>
  </head>
  <body>
    <h2>Font-variant-caps property example</h2>
    <p class="all-small-caps">
      The font-variant-caps CSS property controls the use of alternate glyphs for capital letters.
    </p>
    <p class="small-caps">Small caps!</p>
    <p class="normal">Normal caps!</p>
  </body>
</html>

Result

Values

Values

ValueDescription
normalThe use of alternate glyphs is not activated.
small-capsAllows to display small capitals. Small-caps glyphs use the form of uppercase letters, but are reduced to the size of lowercase letters.
all-small-capsAllows to display small capitals for upper and lowercase letters.
petite-capsAllows to display petite capitals.
all-petite-capsAllows to display petite capitals for upper and lowercase letters.
unicaseAllows to display mixture of small capitals for uppercase letters with normal lowercase letters.
titling-capsAllows to display titling capitals.
initialIt makes the property use its default value.
inheritIt inherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部