22.06.2015 Views

Step by Step HTML5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

60 Chapter 4<br />

Choosing Background and Foreground Colors<br />

Many Web design experts caution against dark or patterned backgrounds on Web<br />

pages, because they can make it difficult to read the text. Some designers go so far as<br />

to say that you should not use any background color at all; they prefer that black text<br />

on a white background be the norm. A quick look at a few major commercial Web sites<br />

will confirm the near-universality of this opinion. Check out high-traffic sites like www.<br />

msn.com, news.google.com, and www.microsoft.com, and you’ll find that the body text is<br />

almost exclusively black (or another dark color) on a white (or other pale) background.<br />

Rules are made to be broken, however, and you might find situations in which a colored<br />

or patterned background is perfect for a certain page (or set of pages). For example,<br />

you might assign a background color to a Web page that you want to differentiate from<br />

other pages of a Web site.<br />

Specifying Colors<br />

The 16 basic colors presented earlier in the section, “Inserting Horizontal Lines,” are the<br />

best colors to use on Web pages because they are universally accepted. Every browser<br />

interprets these colors the same way. However, you will probably find many situations<br />

in which none of those 16 colors is appropriate. For example, you might find that they<br />

are all too dark or too vivid to make an attractive page background. Therefore, you will<br />

sometimes need to rely on other ways of specifying colors.<br />

One way to specify a color is <strong>by</strong> its RGB (red-green-blue) value. Using this method, you<br />

can describe a color using a series of three numbers, from 0 to 255. Each number represents<br />

the component of red, green, or blue that makes up the color. For example, pure<br />

red is 255, 0 ,0; that is, maximum red (255), no green (0), and no blue (0). You can create<br />

a large range of colors using these three values. For example, 255, 153, 0 represents a<br />

particular shade of orange—full red, a little more than half green, and no blue.<br />

Another way to express color values in HTML is <strong>by</strong> using a hexadecimal value. The hexadecimal<br />

values represent the RGB values converted to the base-16 numbering system.<br />

For example, the value 255 converts to FF, so the RGB value 255, 255, 0 can also be<br />

expressed as the hexadecimal value #FFFF00.<br />

The problem with defining colors <strong>by</strong> using RGB or hexadecimal values is that not every<br />

display supports that many colors. Any unsupported colors appear as dithered (that is,<br />

formed with a cross-hatch pattern of two colors blended together). Therefore, most Web<br />

designers try to stick with what are called web-safe colors. A web-safe color is one that<br />

exactly matches one of the colors in a standard 8-bit color display. Web-safe colors use

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!