tadam logo

HTML <body> text Attribute

Example

Specify the color of text in an HTML document:
<html>
<body text="green">

<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="http://Xhtml.co.il">Visit Xhtml.co.il !</a></p>

<p><b>Note:</b> If using color names, different browsers may render different colors, and Firefox have problems if the attribute value is in RGB code (will not display correct color).</p>

<p><b>Tip:</b> To produce equal results in all browsers, always use hex code to specify colors.</p>

<p>However, the text attribute was deprecated in HTML 4, and is not supported in HTML 4.01 Strict DTD or in XHTML 1.0 Strict DTD. Use CSS instead.</p>

</body>
</html>
The output of the code above will be:

Compatibility Notes

The text attribute of <body> is deprecated, and is not supported in HTML 4.01 Strict / XHTML 1.0 Strict DTD.

A deprecated element or attribute is one that has been outdated.
Deprecated elements may become obsolete in the future, but browsers should continue to support deprecated elements for backward compatibility.

Use CSS instead.

CSS syntax (in the <head> section): <style> body{ color:green; } </style>

CSS Example: Set the color of text in a document.

In our CSS tutorial you can find more details about the text color property.

Definition and Usage

The text attribute specifies the color of the text in a document.

Browser Support

The text attribute supported in all major browsers

Syntax

<body text="value">

Attribute Values

ValueDescription
color_nameSpecifies the link color with a color name (like "red")
hex_numberSpecifies the link color with a hex code (like "#ff0000")
rgb_numberSpecifies the link color with an rgb code (like "rgb(255,0,0)")
Was this information helpful?
   

Comments