HTML | DOM Style fontVariant Property

The style fontVariant Property in DOM HTML is used to set the font in capital letters. This property mainly converts lowercase to uppercase letters but the letters have a small font size compared to remaining text.

Syntax:

  • It returns the fontVariant property.
    object.style.fontVariant
  • It used to set the fontVariant property.
    object.style.fontVariant = "normal|small-caps|initial|inherit"

Values:

Value Description
normal Default value with normal text.
small-caps Font in small capital letters
initial Set to default value
inherit Inherit property from parent element

Return Value:

  • It returns a string represents a font in small letters.

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Style fontVariant Property </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;width:40%;"
                GeeksForGeeks 
       </h1>
        <h2>DOM Style fontVariant Property </h2>
  
        <p id="gfg">
            A computer science portal for geeks
        </p>
  
        <button type="button" onclick="geeks()">
            Submit
        </button>
  
        <script>
            function geeks() {
  
                //  Set fontVariant
                document.getElementById(
                        "gfg").style.fontVariant =
                    "small-caps";
            }
        </script>
    </center>
</body>
  
</html>

chevron_right


Output:

Before Click on the button:

After Click on the button:

Example-2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Style fontVariant Property </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;width:40%;"
                GeeksForGeeks 
            </h1>
        <h2>DOM Style fontVariant Property </h2>
        
        <p id="gfg">
          A computer science portal for geeks
      </p>
        
        <button type="button" onclick="geeks()">
            Submit
        </button>
  
        <script>
            function geeks() {
                
                // Set fontVariant
                document.getElementById(
                  "gfg").style.fontVariant = 
                  "all-small-caps";
            }
        </script>
    </center>
</body>
  
</html>

chevron_right


Output:

Before Click on the button:

After Click on the button:

Supported Browsers: The browser supported by DOM Style fontVariant property are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.