text-transform
Example
<button class="btn">
SAVE CHANGES
</button><button class="btn">Save changes</button>
<style>
.btn {
text-transform: uppercase;
}
</style>Keeping normal case in the markup lets design change in CSS and avoids screen readers reading caps oddly.
Common mistakes
capitalizewas expected to make sentence case, but it capitalizes the first letter of every word.- Some screen readers spell out words typed in all caps in the HTML.
Key points
- Text is written in normal case in HTML and made uppercase with
text-transform, not typed in capitals. - Uppercase labels add a little
letter-spacingto stay readable.
Interview questions
How do I make sentence case with CSS?
There is no sentence-case value. Lowercase the text and use ::first-letter with text-transform: uppercase on the element.
Does text-transform change the actual text?
No. It only changes how text is displayed; the DOM text stays the same.