Controlling the document background

You can specify the document background color or image using two different attributes of the <body> tag. Background color simply fills the entire document. Background images are titled by the browser, meaning they are repeated left to right, top to bottom, filling up the visible space of the document.
  • To define a background color for a document, add the bgcolor attribute to the <body> tag
  • Set the bgcolor attribute to a hexadecimal color value of predefined color name. The following example shows you how to set a white background with white text.ß
Example:
------------------------------------
<html>
<head>
<title>Controlling the document background</title>
<meta name="keywords" content="Controlling background, bgcolor, background HTML" />
<meta name="description" content="Controlling background - how to set the background of your document" />
</head>

<body bgcolor="#000000" text="white">

<h1>Controlling the background</h1>

</body>
</html>

------------------------------------
  • To specify a background images, add the background attribute to the <body> tag
  • Set the attribute equal to the path name of the image that you want to use. The following example make use of a titling image
Example:
------------------------------------
<html>
<head>
<title>Controlling the document background</title>
<meta name="keywords" content="Controlling background, bgcolor, background HTML" />
<meta name="description" content="Controlling background - how to set the background of your document" />
</head>

<body background="images/bg.png">

<h1>Controlling the background</h1>
</body>
</html>

------------------------------------