Usage of font-variant property in CSS

The CSS font-variant property controls typographic variations of text, primarily creating small-caps effects where lowercase letters appear as smaller uppercase letters.

Syntax

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

Values

  • normal - Default value, displays text normally
  • small-caps - Converts lowercase letters to smaller uppercase letters
  • initial - Sets to default value
  • inherit - Inherits from parent element

Example: Small Caps Effect

<html>
<head>
    <style>
        .normal-text {
            font-variant: normal;
            font-size: 18px;
            margin: 10px 0;
        }
        .small-caps {
            font-variant: small-caps;
            font-size: 18px;
            margin: 10px 0;
        }
    </style>
</head>
<body>
    <p class="normal-text">This is Normal Text with Mixed Case</p>
    <p class="small-caps">This is Small Caps Text with Mixed Case</p>
</body>
</html>

Practical Applications

Small caps are commonly used for:

  • Headings and subheadings for elegant styling
  • Abbreviations and acronyms (e.g., HTML, CSS)
  • Author names in citations
  • Navigation menus for sophisticated appearance

Example: Navigation Menu

<html>
<head>
    <style>
        .nav-menu {
            font-variant: small-caps;
            font-weight: bold;
            letter-spacing: 1px;
            text-transform: uppercase;
        }
        .nav-menu a {
            text-decoration: none;
            color: #333;
            margin: 0 15px;
        }
    </style>
</head>
<body>
    <nav class="nav-menu">
        <a href="/">home</a>
        <a href="/about">about</a>
        <a href="/services">services</a>
        <a href="/contact">contact</a>
    </nav>
</body>
</html>

Browser Compatibility

The font-variant property is well-supported across all modern browsers. However, the actual small-caps rendering depends on the font family's built-in small-caps glyphs.

Key Points

  • Small caps maintain better readability than full uppercase text
  • Works best with serif fonts that have dedicated small-caps characters
  • Can be combined with other font properties for enhanced styling
  • Preserves the original case of uppercase letters

Conclusion

The font-variant property provides an elegant way to create sophisticated typography using small caps. It's particularly effective for headings, navigation, and stylistic text emphasis while maintaining readability.

Updated on: 2026-03-15T23:18:59+05:30

93 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements