Home > Abakada: Back to Basics > Language References > HTML Element Attributes > TEXT Attribute
Sets or retrieves the foreground ( text ) color for the document BODY.
Inline |
<body TEXT = strColor ... > |
Script |
body.text = strColor ] |
strColor |
String specifying any of the color names or values given in the Color Table. |
The property is read/write with no default value.
Specifying the color as a color name ( for example, "green" ) may not be recognized by some browsers, whereas the RGB color value should always be displayed accurately.
This attribute has been deprecated in favor of the CSS color property.
The following example demonstrates use of the text object property to dynamically set the document BODY's text color. Note that this example will work only for pages whose elements are not formatted using stylesheets.
<body id="oBody">
...
<button onclick="oBody.text='green'">GREEN</button>
<button onclick="oBody.text='red'">RED</button>
<button onclick="oBody.text='blue'">BLUE</button>
Show me
BODY