What You'll Learn
You'll learn how to automatically change the capitalization of text using CSS, without editing your HTML content.
The Core Idea
The text-transform property in CSS lets you control how letters appear—whether they're UPPERCASE, lowercase, or Capitalized—regardless of how they're written in your HTML. Think of it like an automatic formatting filter applied to your text.
Why is this useful? Imagine you have a navigation menu where you want all links in uppercase for visual consistency, but you don't want to type them that way in your HTML (for accessibility and maintenance reasons). text-transform handles this styling layer for you.
The text-transform Values
Here are the main values you can use:
uppercase– Makes ALL LETTERS CAPITALlowercase– makes all letters smallcapitalize– Makes The First Letter Of Each Word Capitalnone– Leaves text as-is (the default)
How It Works
.nav-link {
text-transform: uppercase;
}
.whisper {
text-transform: lowercase;
}
.title {
text-transform: capitalize;
}
<a href="#" class="nav-link">about us</a>
<!-- Displays as: ABOUT US -->
<p class="whisper">STOP SHOUTING</p>
<!-- Displays as: stop shouting -->
<h2 class="title">welcome to our site</h2>
<!-- Displays as: Welcome To Our Site -->
Notice how the HTML content stays readable and accessible, while CSS handles the visual presentation. This separation is a fundamental principle of web development.
Real-World Tip
capitalize affects every word, which can sometimes produce unexpected results with articles or prepositions (like "The" or "Of"). For more precise title casing, you might need JavaScript or careful HTML markup.
Key Takeaway: Use text-transform to control letter casing visually while keeping your HTML content clean and semantic—it's a presentation concern, not a content concern.