English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Reference

HTML: <body> text attribute

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

 HTML <body> tag

Online Example

Specify the color of the text in the HTML document as red:

<!DOCTYPE html>
<html>
<head>
<title>HTML:<body> text attribute</title> - 基础教程网 oldtoolbag.com</title>/title>
<body text="red">
<h1>Hello world!</h1>/h1>
<p>This is some text.</p>/p>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the text attribute.

Definition and Usage

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

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

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

Compatibility notes

In HTML 4.01 It is not recommended to use the text attribute of the body element; in XHTML 1In .0 Strict DTD, the text attribute of the body element is not supported. Please use CSS instead.

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

CSS Example: Set text color in the document

In our CSS tutorial, you can find more about text color attribute Knowledge.

Syntax

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

Attribute value

ValueDescription
color_nameSpecifies the font color with a color name (for example, "red").
hex_numberSpecifies the font color with a hexadecimal value (for example, "#ff0000").
rgb_numberSpecifies the font color with an rgb code (for example, "rgb("255)(
 HTML <body> tag