You are here: Reference > JavaScript > client-side > HTML DOM > properties > text (body)

text property (body)

Browser support:
Specifies or returns the color of the text in the document body.
This property is deprecated. Use the color style property of the body element instead.

Syntax:

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

Possible values:

A legal color value. It can be a hexadecimal, RGB or predefined color value. For more information, see the page for colors.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the text attribute:
<body text="red">
    The color of the text is red.
</body>
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<body style="color:#FF0000;">
    The color of the text is red.
</body>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the text property:
<head>
    <script type="text/javascript">
        function ChangeTextColor () {
            document.body.text = "blue";
        }
    </script>
</head>
<body text="red">
    The color of the text is red.<br />
    <button onclick="ChangeTextColor ()">Change text color</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content