textTransform Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:textTransform

Description

The textTransform property sets or gets the capitalization of a text, for example, uppercase, lowercase or to capitalized.

Property Values

Value Description
none No characters are transformed. This is default
capitalize The first character of each word is transformed to uppercase
uppercase transformed to uppercase
lowercase transformed to lowercase
initialSets this property to its default value.
inheritInherits this property from its parent element.

Technical Details

Item Value
Default Value: none
Return Value: A String, representing the transformation of the text in the element
CSS VersionCSS1

Transform the first letter of each word in a <p> element to uppercase:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="text-transform:lowercase;">This Is An Example PARAGRAPH.</p>

<button type="button" onclick="myFunction()">Return text transformation of p</button>

<script>
function myFunction() {/*  w w  w.  j a va  2 s .c  om*/
    document.getElementById("myP").style.textTransform = 'uppercase';
}
</script>

</body>
</html>

Related Tutorials