HTML <body> textAttributes

HTML body 标签参考手册HTML <body> Tag

Examples

Set the text color in an HTML document:

<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="../index.html">Visit example.com!</a></p>

Try it »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the text attribute.


Definition and Usage

HTML5 no longer supports the <body> text attribute. Use CSS instead.

The text attribute of <body> is deprecated in HTML 4.01. in HTML 4.01.

The text attribute specifies the text color of an HTML document.


Compatibility Notes

In HTML 4.01, the text attribute of the body element is deprecated; in XHTML 1.0 Strict DTD, the text attribute of the body element is not supported. Use CSS instead.

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

CSS example: set the text color in a document

In our CSS tutorial, you can find more information abouttext color propertyknowledge.


Syntax

<body text="color_name|hex_number|rgb_number">

Attribute Values

Value Description
color_name Specifies the font color with a color name (like "red").
hex_number Specifies the font color with a hexadecimal value (like "#ff0000").
rgb_number Specifies the font color with an rgb code (like "rgb(255,0,0)").


HTML body 标签参考手册HTML <body> Tag Other Extensions