The text-transform
property specifies how words or individual letters are displayed in capital letters.
It can be used to display text in all-uppercase letters, all-lowercase, or to capitalize words (make first letter of each word a capital letter).
Official Syntax
-
Syntax:
text-transform: none | capitalize | uppercase | lowercase | full-width
- Initial: none
- Applies To: all elements
- Animatable: no
Values
- none
- No effect is applied to the text. It prevents any change to the case of the characters.
- capitalize
- Converts the first letter of each word to uppercase. Other letters in each word are not affected, they retain their original case (whether upper or lower) as written in the element’s text source.
- uppercase
- forces all letters to uppercase.
- lowercase
- forces all letters to lowercase.
- full-width
-
Forces the writing of a character, mainly ideograms and Latin scripts inside a square, allowing them to be aligned in the usual East Asian scripts (like Chinese or Japanese).
Some characters exists in two formats, normal width and a full-width, with different Unicode code points. The full-width version is used to mix them smoothly with Asian ideographic characters. If the character does not have a corresponding full width form, it is left as is.
Notes
The text-transform
property cascades, so you may want or need to reset its value (set it to none
) on an element’s child to prevent the text inside that child from being affected by the transformation of its parent.
Examples
The following forces all the h1
elements to be displayed in all-uppercase letters.
h1 { text-transform: uppercase; }
The following will capitalize each word in all the h2
tags.
h2 { text-transform: capitalize; }
Live Demo
View this demo on the Codrops PlaygroundBrowser Support
The text-transform
property is supported in all major browsers: Chrome, Firefox, Safari, Opera, IE and on Android and iOS.
Notes
The full-width
value is only supported in Firefox at this time starting from version 19.0.
The CSS Text Level Module 4 adds a new value full-size-kana
which is still experimental and not yet supported by any browser.