Monday, 2 February 2015

HTML provides you with control over the colors of items on your pages. There are two ways to specify a color. The easiest is to simply use the color name. You can select from the following 16 keywords:

Aqua, black, blue, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white and yellow.

The second way, which allows specifying any color you want, is using hex codes. This is the preferred way to specify colors because it is universally understood and you will never get stuck trying to find the name for that certain shade of green. To use this technique, you need to understand how colors on a computer screen are created. Any color is a combination of the three primary colors red, green and blue. This is why you will sometimes see computer colors referred to as RGB (Red Green Blue) colors. In any given color, each of the three primary colors has a value ranging from 0 (none) to 255 (maximum), so any color can be represented by its RGB value of three numbers. There are three formats for doing this:

Use the RGB (r, g, b) function, where r, g and b are numbers in the range from 0 to 25 that specify the level of red, green and blue, respectively.
Use a hexadecimal (base 16) numbers in the form #RRGGBB, where RR, GG and BB are each a hexadecimal number in the range 00-FF (0-255 in decimal notation).
Use the rgb (r%, g%, b%) function, where r, g and b are numbers in the range 0 to 100 that specify the level of red, blue and green as a percentage of the maximum.

Table below some examples of colors using the rgb() function and hexadecimal notation. You can experiment with colors using your HTML editor and browser to see what different values look like

Color NameColor CodeColor NameColor Code
Red#FF0000White#FFFFFF
Cyan#00FFFFSilver#C0C0C0
Blue#0000FFGray or Grey#808080
DarkBlue#0000A0Black#000000
LightBlue#ADD8E6Orange#FFA500
Purple#800080Brown#A52A2A
Yellow#FFFF00Maroon#800000
Lime#00FF00Green#008000
Magenta#FF00FFOlive#808000

A full list of HTML color codes can be found at http://www.computerhope.com/htmcolor.htm

0 comments:

Post a Comment