Sams Teach Yourself HTML 4 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Put Your HTML Page Online Today
- I. Your First Web Page
- Hour 1. Understanding HTML and XML
- Hour 2. Create a Web Page Right Now
- Hour 3. Linking to Other Web Pages
- Hour 4. Publishing Your HTML Pages
- II. Web Page Text
- Hour 5. Text Alignment and Lists
- Hour 6. Text Formatting and Font Control
- Hour 7. Email Links and Links Within a Page
- Hour 8. Creating HTML Forms
- III. Web Page Graphics
- Hour 9. Creating Your Own Web Page Graphics
- Hour 10. Putting Graphics on a Web Page
- Hour 11. Custom Backgrounds and Colors
- Hour 12. Creating Animated Graphics
- IV. Web Page Design
- Hour 13. Page Design and Layout
- Hour 14. Graphical Links and Imagemaps
- Hour 15. Advanced Layout with Tables
- Hour 16. Using Style Sheets
- V. Dynamic Web Pages
- Hour 17. Embedding Multimedia in Web Pages
- Hour 18. Interactive Pages with Applets and ActiveX
- Hour 19. Web Page Scripting for Non-Programmers
- Hour 20. Setting Pages in Motion with Dynamic HTML
- VI. Building a Web Site
- Hour 21. Multipage Layout with Frames
- Hour 22. Organizing and Managing a Web Site
- Hour 23. Helping People Find Your Web Pages
- Hour 24. Planning for the Future of HTML
- VII. Appendixes
- A. Readers' Most Frequently Asked Questions
- B. HTML Learning Resources on the Internet
- C. Complete HTML 4 Quick Reference
- D. HTML Character Entities
Creating Custom Colors
If the 16 named colors don't include the exact hue you're after, you can mix your own custom colors by specifying how much red, green, and blue light should be mixed into each color.
The format is # rrggbb where rr,gg, and bb are two-digit hexadecimal values for the red, green, and blue components of the color. If you're not familiar with hexadecimal numbers, don't sweat it. Just remember that ff is the maximum and 00 is the minimum, and use one of the following codes for each component:
- ff means full brightness
- cc means 80 percent brightness
- 99 means 60 percent brightness
- 66 means 40 percent brightness
- 33 means 20 percent brightness
- 00 means none of this color component
For example, bright red is #ff0000, dark green is #003300, bluish-purple is #660099, and medium-gray is #999999. To make a page with a red background, dark green text, and bluish-purple links that turn white when you click them and gray when you've visited them, the HTML would look like the following:
<body bgcolor="#ff0000" text="#003300" link="#660099" alink="#ffffff" vlink="#999999">
Though the colors you specify in the <body> tag apply to all text on the page, you can also use either color names or hexadecimal color codes to change the color of a particular word or section of text by using the <font> tag. This is discussed in Hour 6, "Text Formatting and Font Control."
Keep in mind that even though you can specify millions of different colors, some computers are set to display only the 16 named colors. Other computers only reliably display the 216 colors in the color code reference mentioned in the previous tip. All others will be approximated by dithered patterns, which can make text look messy and difficult to read.
Also, you should be aware that different computer monitors may display colors in very different hues. I recently designed a page with a beautiful blue background for a company I work for, only to find out later that the president of the company saw it on his computer as a lovely purple background! Neutral, earth-tone colors such as medium gray, tan, and ivory can lead to even more unpredictable results on many computer monitors, and may even seem to change color on one monitor depending on lighting conditions in the room and the time of day.
The moral of the story: Stick to the named colors and don't waste time mucking with hexadecimal color codes, unless you have precise control over your intended audience's computer displays—and to be safe, do test your page on different monitors if possible.
Background Image Tiles | Next Section

Account Sign In
View your cart