Latest web development tutorials

HTML DOM Style textTransform property

Style Object Reference Style Objects

Definition and Usage

textTransform property sets or returns the text of the case.

grammar

Setting textTransform properties:

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

Back textTransform properties:

Object.style.textTransform

描述
none 默认。没有被转换的字符。
capitalize 每个单词的首字符转换为大写。
uppercase 所有字符都转换为大写。
lowercase 所有字符都转换为小写。
inherit textTransform 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support textTransform property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

The first letter of each word to uppercase:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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()">转换文本首字符为大写</button>

</body>
</html>

try it"


Style Object Reference Style Objects