The Wayback Machine - https://web.archive.org/web/20250114182048/https://www.geeksforgeeks.org/css-font-variant-property/
Open In App

CSS font-variant Property

Last Updated : 27 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The font-variant property is used to convert all lowercase letters into uppercase letters. However, the converted upper letters appear too small compared to the original uppercase letters. 

Syntax:  

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

Default Value: normal  

Property Values:

  • normal: It has a default value. It specifies a normal font size.
  • small-caps: It converts all the lowercase letters into uppercase letters.
  • initial: It sets the property to its default value.

Example: In this example, we use font-variant: normal; property.

html
<!DOCTYPE html>
<html>
<head>
    <style>
        h1 {
            color: green;
        }

        p.geeks {
            font-variant: normal;
        }
    </style>
</head>

<body>
    <center>
        <h1>GeeksForGeeks</h1>
        <h2>font-variant:normal;</h2>
        <p class="geeks">GeeksForGeeks.</p>
        <p>It is a computer science portal for geeks.</p>

    </center>
</body>
</html>

Output: 

Example: In this example, we are using font-variant:small-caps; property.

html
<!DOCTYPE html>
<html>
<head>
    <style>
        h1 {
            color: green;
        }

        p.geeks {
            font-variant: small-caps;
        }

        .gfg {
            font-variant: small-caps;
        }
    </style>
</head>

<body>
    <center>
        <h1>GeeksForGeeks</h1>
        <h2>font-variant:small-caps;</h2>
        <p class="geeks">GeeksForGeeks.</p>
        <p class="gfg">
            It is a computer science
            portal for geeks.
        </p>
    </center>
</body>
</html>

Output: 

Example:  In this example, we use font-variant: initial; property.

html
<!DOCTYPE html>
<html>
<head>
    <style>
        h1 {
            color: green;
        }

        p.geeks {
            font-variant: initial;
        }

        .gfg {
            font-variant: initial;
        }
    </style>
</head>

<body>
    <center>
        <h1>GeeksForGeeks</h1>
        <h2>font-variant:initial;</h2>
        <p class="geeks">GeeksForGeeks.</p>
        <p class="gfg">
            It is a computer science
            portal for geeks.
        </p>
    </center>

</body>
</html>

Output: 

Supported Browsers: The browser supported by CSS font-variant property are listed below: 

  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Internet Explorer 4.0 and above
  • Firefox 1.0 and above
  • Opera 3.5 and above
  • Apple Safari 1.0 and above

CSS font-variant Property – FAQs

What does the font-variant property do in CSS?

The font-variant property in CSS is used to control the use of small-caps or other text variations. It can create stylistic changes, like displaying lowercase letters as smaller uppercase letters.

What values can font-variant accept?

The font-variant property commonly accepts values like normal and small-caps. “Small-caps” transforms lowercase text into smaller uppercase characters.

How is font-variant used with OpenType features?

In addition to small-caps, font-variant can be expanded to control OpenType features using properties like font-variant-ligatures, font-variant-numeric, and others. This allows for more granular typography control.

Is font-variant widely supported across browsers?

The basic usage of font-variant, like small-caps, is widely supported across all major browsers. However, more advanced variants may have varied support, especially in older browsers.

What is the default value of font-variant?

The default value of font-variant is normal, meaning no special styling, like small-caps, is applied to the text.


Dive deep into the world of JavaScript with our JavaScript Full Course Online, offering everything from the basics to advanced techniques. Learn how to build interactive websites, optimize your code, and earn a certification to showcase your skills.

Take the Three 90 Challenge! Complete 90% of the course in 90 days, and earn a 90% refund. Push your limits and stay motivated as you work towards mastering JavaScript. Join now and get started on your JavaScript learning journey!


Next Article

Similar Reads

three90RightbarBannerImg