Home

How to Use Color Names for Your HTML5 and CSS3 Based Web Pages

|
Updated:  
2016-03-26 13:17:51
|
HTML5 and CSS3 All-in-One For Dummies
Explore Book
Buy On Amazon

Using color names in CSS3 seems like the easiest solution, and, for basic colors, they work fine. However, here are some problems with color names that make them troublesome for web developers:

  • Only 16 color names will validate. Although most browsers accept hundreds of color names, only 16 are guaranteed to validate in CSS and HTML validators. See the following table for a list of those 16 colors.

  • Color names are somewhat subjective. You'll find different opinions on what exactly constitutes any particular color, especially when you get to the more obscure colors.

  • It can be difficult to modify a color. For example, what color is a tad bluer than…?

  • They're hard to match. Say you're building an online shrine to your cat and you want the text to match your cat's eye color. It'll be hard to figure out exactly what color name corresponds to your cat's eyes.

Hex codes are included in this table for completeness. It’s okay if you don’t understand what they’re about.

ColorHex Value
Black #000000
Silver #C0C0C0
Gray #808080
White #FFFFFF
Maroon #800000
Red #FF0000
Purple #800080
Fuchsia #FF00FF
Green #008800
Lime #00FF00
Olive #808000
Yellow #FFFF00
Navy #000080
Blue #0000FF
Teal #008080
Aqua #00FFFF

About This Article

This article is from the book: 

About the book author:

Andy Harris earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
Andy has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
Andy welcomes comments and suggestions about his books. He can be reached at [email protected].