Summary
The text-transform
CSS property specifies how to capitalize an element's text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.
The text-transform
property takes into account language-specific case mapping rules, like:
-
in Turkic languages, like Turkish (
tr
), Azerbaijani (az
), Crimean Tatar (crh
), Volga Tatar (tt
), and Bashkir (ba
), there are two kinds of i, with and without the dot, and two case pairings:i
/İ
andı
/I
. -
In German (
de
), theß
becomesSS
in uppercase. -
In Dutch (
nl
), theij
digraph becomesIJ
, even withtext-transform: capitalize
, which only put the first letter of a word in uppercase. -
In Greek (
el
), vowels lose their accent when the whole word is in uppercase (ά
/Α
), except for the disjunctive eta (ή
/Ή
). Also, diphthongs with an accent on the first vowel lose the accent and gain a diaeresis on the second vowel (άι
/ΑΪ
). -
In Greek (
el
), the lowercase sigma character has two forms:σ
andς
.ς
is used only when sigma terminates a word. When applyingtext-transform: lowercase
to an uppercase sigma (Σ
), the browser needs to choose the right lowercase form based on context.
On the other some other specific case mapping rules are not taken into account by any browser like:
- in Gaelic (
ga
), a prefix letter remains in lowercase when the base initial is capitalised, so in this example theh-
should not be capitalized:text-transform: uppercase
will changeMeud na h-aplacaid
toMEUD NA H-APLACAID
which violates the locale orthographic rules, as it ought to beMEUD NA h-APLACAID.
The language is defined by the lang
HTML attribute or the xml:lang
XML attribute.
Support for these specific cases vary from one browser to the other, so check the browser compatibility table.
Initial value | none |
---|---|
Applies to | all elements. It also applies to ::first-letter and ::first-line . |
Inherited | yes |
Media | visual |
Computed value | as specified |
Animatable | no |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
/* Keyword values */ text-transform: capitalize; text-transform: uppercase; text-transform: lowercase; text-transform: none; text-transform: full-width; /* Global values */ text-transform: inherit; text-transform: initial; text-transform: unset;
Values
capitalize
Is a keyword forcing the first letter of each word to be converted to uppercase. Other characters are unchanged; that is, they retain their original case as written in the element's text. A letter is any Unicode character part of the Letter or Number general categories : it excludes any punctuation marks or symbols at the beginning of the word.
Authors should not expectcapitalize
to follow language-specific titlecasing conventions (such as skipping articles in English).uppercase
- Is a keyword forcing all characters to be converted to uppercase.
lowercase
- Is a keyword forcing all characters to be converted to lowercase.
none
- Is a keyword preventing the case of all characters to be changed.
full-width
- Is a keyword forcing 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).
Formal syntax
none | capitalize | uppercase | lowercase | full-width
Examples
p { text-transform: none; } |
|
Initial string | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Live example | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Reference result | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
p { text-transform: capitalize; } |
|
Initial string | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Live example | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Reference result | Lorem Ipsum Dolor Sit Amet, Consectetur Adipisicing Elit, ... |
p { text-transform: capitalize; } Initial punctuations of a word are ignored. The keyword target the first letter, that is the first Unicode character part of the Letter or Number general category. |
|
Initial string | (this) “is” [a] –short– -test- «for» *the* _css_ ¿capitalize? ?¡transform! |
Live example | (this) “is” [a] –short– -test- «for» *the* _css_ ¿capitalize? ?¡transform! |
Reference result | (This) “Is” [A] –Short– -Test- «For» *The* _Css_ ¿Capitalize? ?¡Transform! |
p { text-transform: capitalize; } Initial symbols are ignored. The keyword target the first letter, that is the first Unicode character part of the Letter or Number general category. |
|
Initial string | ⓐⓑⓒ (ⓓⓔⓕ) —ⓖⓗⓘ— ⓙkl |
Live example | ⓐⓑⓒ (ⓓⓔⓕ) —ⓖⓗⓘ— ⓙkl |
Reference result | ⓐⓑⓒ (ⓓⓔⓕ) —ⓖⓗⓘ— ⓙKl |
p { text-transform: capitalize; } The Dutch ij digraph must be handled like one single letter |
|
Initial string | The Dutch word: "ijsland" starts with a digraph. |
Live example | The Dutch word: "ijsland" starts with a digraph. |
Reference result | The Dutch Word: "IJsland" Starts With A Digraph. |
p { text-transform: uppercase; } |
|
Initial string | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Live example | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Reference result | LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISICING ELIT, ... |
p { text-transform: uppercase; } Greek vowels except disjunctive eta should have no accent, and the accent on the first vowel of a vowel pair becomes a diaeresis on the second vowel |
|
Initial string | Θα πάμε στο "Θεϊκό φαΐ" ή στη "Νεράιδα"; |
Live example | Θα πάμε στο "Θεϊκό φαΐ" ή στη "Νεράιδα"; |
Reference result | ΘΑ ΠΑΜΕ ΣΤΟ "ΘΕΪΚΟ ΦΑΪ" Ή ΣΤΗ "ΝΕΡΑΪΔΑ"; |
p { text-transform: lowercase; } |
|
Initial string | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Live example | Lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
Reference result | lorem ipsum dolor sit amet, consectetur adipisicing elit, ... |
p { text-transform: lowercase; } The Greek character sigma ( Σ ) is transformed into the regular lowercase sigma (σ ) or the word-final variant (ς ), according the context. |
|
Initial string | Σ IS A greek LETTER that appears SEVERAL TIMES IN ΟΔΥΣΣΕΥΣ. |
Live example | Σ IS A greek LETTER that appears SEVERAL TIMES IN ΟΔΥΣΣΕΥΣ. |
Reference result | σ is a greek letter that appears several times in ΟΔΥΣΣΕΥ ς. |
p { text-transform: full-width; } 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. |
|
Initial string | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@{|}~ |
Live example | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@{|}~ |
Reference result | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@{|}~ |
Specifications
Specification | Status | Comment |
---|---|---|
CSS Text Level 4 The definition of 'text-transform' in that specification. |
Working Draft | From CSS Text Level 3 The definition of 'text-transform' in that specification., adds the full-size-kana keyword and allows the full-width keyword to be used together with another keyword. |
CSS Text Level 3 The definition of 'text-transform' in that specification. |
Working Draft | From CSS Level 2 (Revision 1) The definition of 'text-transform' in that specification., extends letters to any Unicode character in the Number or Letter general category. Modifies the behavior of capitalize to apply to the first letter of the word, ignoring initial punctuations or symbols. Adds the full-width keyword to mix smoothly ideographic characters and alphabetical characters. |
CSS Level 2 (Revision 1) The definition of 'text-transform' in that specification. |
Recommendation | From CSS Level 1 The definition of 'text-transform' in that specification., extends letters to non-latin bi-cameral scripts |
CSS Level 1 The definition of 'text-transform' in that specification. |
Recommendation | Initial definition |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.7 or earlier) | 4.0 | 7.0 | 1.0 |
capitalize (CSS3 version) |
?[1] | 14 (14)[1] | ?[1] | ?[1] | ?[1] |
full-size-kana |
No support | No support | No support | No support | No support |
full-width |
No support | 19 (19) | No support | No support | No support |
ß → SS |
? | 1.0 (1.7 or earlier) | ? | ? | ? |
i → İ and ı → I |
No support | 14 (14) | ? | ? | No support |
Dutch IJ digraph |
No support | 14 (14) | No support | No support | No support |
Greek accented letters | 30 | 15 (15) | No support | No support | No support |
Σ → σ or word-final ς |
30 | 14 (14) | No support | No support | 6.0 |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1) | 6.0 | 6.0 | 1.0 |
capitalize (CSS3 version) |
?[1] | 14.0 (14)[1] | ?[1] | ?[1] | ?[1] |
full-size-kana |
No support | No support | No support | No support | No support |
full-width |
No support | 19.0 (19) | No support | No support | No support |
ß → SS |
? | 1.0 (1) | ? | ? | ? |
i → İ and ı → I |
No support | 14.0 (14) | ? | ? | No support |
Dutch IJ digraph |
No support | 14.0 (14) | No support | No support | No support |
Greek accented letters | No support | No support | No support | No support | No support |
Σ → σ or word-final ς |
No support | 14.0 (14) | No support | No support | No support |
[1] The capitalize
keyword was under-specified in CSS 1 and CSS 2.1. There were differences between browsers in the way the first letter was calculated (Firefox considered - and _ as letters, but not the others. Both Webkit and Gecko incorrectly considered letter-based symbols like ⓐ
to be real letters. Internet Explorer 9 was the closest to the CSS 2 definition, but with some weird cases). By precisely defining the correct behavior, CSS Text Level 3 cleans this mess up. The capitalize
line in the browser compatibility table contains the version the different engines started to support this now precisely defined behavior.