You are here: Reference > JavaScript > client-side > style handling > properties > textTransform

textTransform style property

Browser support:
Specifies or returns the case of the text.
With this property you can change text to uppercase, lowercase or to capitalized.

Syntax:

object.textTransform;
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: text-transform

Possible values:

The type of this property is string.
 One of the following values: 
capitalize
Uppercases the first letter of each word.
inherit
Takes the value of this property from the computed style of the parent element.
lowercase
Lowercases all letters of each word.
none
No text transformation is used.
uppercase
Uppercases all letters of each word.
Default: none.

Example HTML code 1:

This example illustrates the use of the text-transform property:
<head>
    <style>
        .example {
            text-transform: capitalize;
        }
    </style>
</head>
<body>
    <p class="example">text-transform</p>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the textTransform property in JavaScript:
<head>
    <script type="text/javascript">
        function ChangeTextTrans (selectTag) {
            // Returns the index of the selected option
            var whichSelected = selectTag.selectedIndex;

            // Returns the text of the selected option
            var transValue = selectTag.options[whichSelected].text;

            var div = document.getElementById ("myDiv");
            div.style.textTransform = transValue;
        }
    </script>
</head>
<body>
    <div id="myDiv">Change text-transform FOR this text</div>

    <br />
    <select size="4" onchange="ChangeTextTrans (this);">
        <option selected="selected" />none
        <option />capitalize
        <option />uppercase
        <option />lowercase
    </select>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content