font-variant

CSS font-variant Property

The font-variant property sets the text as normal or small-caps from a font-family.

The font-variant property can have two values: normal and small-caps. Normal is the default value. When we select small-caps for a text, it makes the lowercase letters to the uppercase letters, but these converted letters will be displayed a little smaller than normal uppercase letters.

The font-variant property can be included as part of a font shorthand declaration.

This property has been extended in CSS3. In CSS3, the font-variant property can become a shorthand and take several values (e.g., petite-caps, all-petite-caps, all-small-caps, titling-capes).

类目类目
Initial Valuenormal
Applies toAll elements. It also applies to ::first-letter and ::first-line.
InheritedYes.
AnimatableNo.
VersionCSS1
DOM Syntaxobject.style.fontVariant = “normal”;

Syntax

Syntax

font-variant: normal | small-caps | initial | inherit;

Example of the font-variant property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .smallcaps {
        font-variant: small-caps;
      }
    </style>
  </head>
  <body>
    <h2>Font-variant property example</h2>
    <p>Here we used a normal text as you can see.</p>
    <p class="smallcaps">But We Used A Text With Small-Caps Here.</p>
  </body>
</html>

Result

Values

Values

ValueDescriptionPlay it
normalMeans that text characters will be normal. This is the default value of this property.Play it »
small-cupsThe browser displays a small-caps font.Play it »
initialMakes the property use its default value.Play it »
inheritInherits the property from its parents element.


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

扫一扫,反馈当前页面

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