The World Wide Web Consortium (W3C) has listed 16 valid color names for HTML and CSS: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. There are also Extended Color names such as: darkblue, dodgerblue, mediumblue, skyblue, aquamarine, brown, beige, crimson, gold, hotpink, indigo, magenta, tan, violet…
Obviously, there is a limit to the number of possible color names. However, HTML can use either
RGBRGB
RGB refers to the common color model where red, green, and blue are combined in various ways to produce millions of possible colors. This model is based on the three primary colors of red, green, and blue.
triplet values or
HEXHEX
HEX is short for Hexadecimal which is also known as base 16, because it has 16 digits (as opposed to decimal, which is base 10 with 10 digits). In Hex, the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen. Hexadecimal is also commonly used to represent computer memory addresses which are based on the size of a byte, which is comprised of eight bits.
triplet values to represent millions of colors:
Dec: base 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17... 253, 254, 255
Hex: base 16: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12 ... FD, FE, FF
RGB values can represent 255*255*255 colors, and likewise Hex values can represent FF*FF*FF colors. The first segment is used for red, the second secment is used for green, and the third segment or triplet is used to represent the blue value. The higher the number in the blue triplet, the brighter the blue. A value of 00 in the last triplet means that there is absolutely no blue present. The total number of values for each triple is actually 256 (0 through 255). And 256 raised to the power of 3 results in over 16.7 million possible colors that can be displayed in RGB or Hex notation with today's browsers.
The following three in-line style statements all display the text "abc" in blue:
<p style="color:RGB(0, 0, 255)">abc</p>
<!-- the above code uses an RGB triplet to represent the color blue -->
Or
<h2 style="color:#0000FF">abc</h2>
<!-- the above code uses a Hex value to represent the color blue -->
Or
<span style="color:blue">abc</span>
All <h1> tags for the entire Website can be set to blue with the following Cascading Style statement:
h1 {color:#0000FF} /* blue */
You could set both the background color and the font color of a Web page with the following line of code:
<body style="background-color:yellow; color:#3300FF">
<body bgcolor="yellow"> <!-- bgcolor has been deprecated -->
Below is a small and simple chart of Web page colors:
Color | Hex value | RGB Value |
Red | #FF0000 | RGB(255,0,0) |
Maroon | #800000 | RGB(128,0,0) |
Olive | #808000 | RGB(128,128,0) |
Lime | #00FF00 | RGB(0,255,0); |
Green | #008000 | RGB(0,128,0) |
Blue | #0000FF | RGB(0,0,255) |
Navy | #000080 | RGB(0,0,128) |
Yellow | #FFFF00 | RGB(255,255,0) |
Aqua | #00FFFF | RGB(0,255,255) |
Teal | #008080 | RGB(0,128,128) |
Fuchsia | #FF00FF | RGB(255,0,255) |
Purple | #800080 | RGB(128,0,128) |
Black | #000000 | RGB(0,0,0) |
White | #FFFFFF | RGB(255,255,255) |
Silver | #C0C0C0 | RGB(192,192,192) |
Gray | #808080 | RGB(128,128,128) |
Note 1: There are other shades of gray:
#333333 or #666666 or #999999 or #CCCCCC or #C0C0C0
For a more detailed chart see the W3Schools link:
http://w3schools.com/html/html_colors.asp
and
http://www.w3schools.com/HTML/html_colornames.asp
Practice adding colors to the text of a practice Web page. Use inline styles and cascading styles, use Hex and RGB values.
For more HTML code samples see: www.w3schools.com
For other resources and tutorials see: quackit.com and htmlquick.com
ValidateValidate
Validation checks the syntax of your file, looking for both errors and possible issues when viewing your page in a browser. Some of the problems reported are missing end tags, missing characters, invalid attributes, incorrect nesting of elements... your file, see: http://validator.w3.org
Review Assignment Learning Project: 10 Practice Review Steps