Document Colors and Background Images
The HTML 4 and XHTML standards provide a number of attributes for
the <body>
tag that let you
define text, link, and document background colors, in addition to defining an image to be used as the
document background. All the popular browsers additionally extend these
attributes to include document margins and better background image
control. And, of course, the latest stylesheet technologies integrated
into the current browsers let you manipulate all of these various
display parameters.
Additions and Extensions to the <body> Tag
The attributes that control the document background, text color,
and document margins are used with the <body>
tag. [<body>, 3.8.1]
The bgcolor attribute
One standard, although deprecated, way you can change
the default background color in the browser window to another hue is with
the bgcolor
attribute for the
<body>
tag. Like the color
attribute for the <font>
tag, the required value of
the bgcolor
attribute may be
expressed in either of two ways: as the red, green, and blue (RGB)
components of the desired color, or as a standard color name. Appendix G provides a complete
discussion of RGB color encoding along with a table of acceptable
color names you can use with the bgcolor
attribute.
Setting the background color is easy. To get a pure red background using RGB encoding, try:
<body bgcolor="#FF0000">
For a subtler background, try:
<body bgcolor="peach">
The background attribute
If a splash of color isn't enough, you may ...
Get HTML & XHTML: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.