Style textTransform attribute
- Previous Page textShadow
- Next Page top
- Go Up One Level HTML DOM Style Object
Definition and usage
textTransform
Attribute sets or returns the case of the text.
This attribute is used to modify text to uppercase, lowercase, or capitalize the first letter.
See also:
CSS Tutorial:CSS Text
CSS Reference Manual:text-transform attribute
Example
Example 1
Convert the first letter of each word in the <p> element to uppercase:
document.getElementById("myP").style.textTransform = "capitalize";
Example 2
Convert all characters in the <p> element to uppercase:
document.getElementById("myP").style.textTransform = "uppercase";
Example 3
Return the text transformation of the <p> element:
alert(document.getElementById("myP").style.textTransform);
Syntax
Return textTransform attribute:
object.style.textTransform
Set textTransform attribute:
object.style.textTransform = "none|capitalize|uppercase|lowercase|initial|inherit"
Attribute value
Value | Description |
---|---|
none | No characters are converted. Default. |
capitalize | The first character of each word is converted to uppercase. |
uppercase | All characters are converted to uppercase. |
lowercase | All characters are converted to lowercase. |
initial | Set this attribute to its default value. See initial. |
inherit | This attribute is inherited from its parent element. See inherit. |
Technical details
Default value: | None |
---|---|
Return value: | A string representing the transformation of the element's Chinese text. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page textShadow
- Next Page top
- Go Up One Level HTML DOM Style Object