Colors on a Web Page

Colors on a Web page may be inserted in two ways. It may be inserted either with the name of the color or with hexadecimal numbers that represent the RGB (Red-Green-Blue) equivalent. The RGB color value is used by graphics programs, such as Paint Shop Pro.

The following tags both provide a white background: <body bgcolor="white"> or <body bgcolor="#ffffff">

Colors

Color Name RGB Color Code Dec RGB Color Code Hex
white 255 255 255 ffffff
black 0 0 0 000000

Color Names

Your textbook lists all the Netscape supported color names in Appendix F.

RGB (Red, Green, and Blue) Color Codes

Graphics programs use the RGB color value represented by either three decimal numbers or three hexadecimal numbers. The decimal numbers used are 0 through 255 separated by a space. For example, white is 255 255 255 and black is 0 0 0. The hexadecimal number looks like this: white is ffffff and black is 000000.

Before we can use a color on a Web page for background or font color we need to convert the decimal RGB value to hexadecimal RGB value.

The hexadecimal number system uses 16 as the base, employing the numbers 0 through 9 and representing digits greater than 9 with the letters A through F.

To convert the RGB decimal code to hex you can use the scientific calculator available in Windows under Accessories.


Birte Nebeker, Raritan Valley Community College
Created 1996
Last modified: