Home   Web Top   Bottom Contents   Prev   Next

Background Colors and Images

Topics on This Page

Background Colors and Images
Text Color


Background Colors and Images

In the <body> tag, you can specify a background color and/or a background image for your page. If you want your background to be a solid color, just specify a background color. If you want to use a background image, specify BOTH a background color AND the background image, and make the background color as similar as possible to the background image. The reasons for this are:

The bgcolor attribute of <body> specifies the background color. You can use the 16 color names (bgcolor="red") or you can use a # followed by a 6-character hex code (bgcolor="#ffcccc") just like we did with the color CSS property. You'll want to refer to a color chart when choosing your background colors. Here's the link to my color chart (opens in a new window):

    Larry's color charts

The background attribute of <body> specifies the background image. Code the value just like you would a src attribute of <img>.

Example of a background image This is the background image that is used in the following example. When you display the page, note how the browser tiles it by repeating it over and over both horizontally and vertically when you display the page.

Here's an example of a web page that includes a background color and image. Things to try:


Text Color

The <body> tag also has attributes for setting the text colors for the page. These attributes are:

text   Specifies the color of all text except link text

link   Specifies the color of link text for an unvisited link

vlink  Specifies the color of link text for a visited link

alink  Specifies the color of link text while the mouse button is
       pressed while over the link

The text color defaults to black. The link color defaults to blue. The vlink color defaults to purple. The alink color defaults to red. If these colors don't work well with your chosen background color/image, be sure to specify values for these attributes. If you're using CSS to specify the colors for your text, be sure to include the <body> attributes as well — non-CSS browsers will recognize the attributes in the <body> tag but will not recognize the colors in your CSS.

Here is an example that shows how these attributes can be used. Things to try:


Home   Web Top   Bottom Contents   Prev   Next