Style textTransformProperty

Style 对象参考手册Style Object

Definition and Usage

The textTransform property sets or returns the case of a text.

Syntax

Set the textTransform property:

Object.style.textTransform="none|capitalize|uppercase|lowercase|inherit"

Return the textTransform property:

Object.style.textTransform

Value Description
none Default. No characters are converted.
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.
inherit The value of the textTransform property is inherited from the parent element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the textTransform property.

Note:IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Convert the first letter of each word to uppercase:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function displayResult(){
    document.getElementById("p1").style.textTransform="capitalize";
}
</script>
</head>
<body>

<p id="p1">This is some text.</p>
<br>
<button type="button" onclick="displayResult()">Convert the first character of the text to uppercase</button>

</body>
</html>

Try it Yourself »


Style 对象参考手册Style Object Other Extensions