ARCHIVED: In HTML, how do I change the color of the text and background of a web page?

To change the color of the text and background of a web page, you need to include extra attributes within the HTML <body> tag. If the site you are creating contains more than one page, you can specify these attributes for all your pages in a single style sheet. For more, see ARCHIVED: What is CSS?

Use the bgcolor attribute to change the background color, as follows:

  <body bgcolor="#rrggbb">

The color value is specified with two hexadecimal digits each for red, green, and blue intensities. A value of 00 is darkest and ff is lightest, with intermediate values specifying shades in between. To specify white, for example, use #ffffff. To specify bright blue, use #0000ff. For purple, use #ff00ff. For more, see ARCHIVED: What are the RGB values of some common colors?

You can use other attributes in a similar way to specify the colors used to display text. Use the text attribute for normal text, the link attribute for unvisited links, the vlink attribute for previously visited links, and the alink attribute for active links. (A link becomes active when you click it.) For example, to make all normal text appear white and all links appear red, you would use:

  <body text="#ffffff" link="#ff0000" vlink="#ff0000" alink="#ff0000">

You can also change the text color of individual words or sections rather than entire documents by using the <font> tag with the color attribute, for example:

  <font color="#000000">

You can use any of the hexadecimal numbers representing colors, as described above. To turn off the color change, use a </font> tag.

Choose your colors carefully so that your text will be easily visible. For example, if you're using a dark background color, you should use light colors for text and links to ensure legibility.

This is document abaa in the Knowledge Base.
Last modified on 2014-12-18.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.