If you just wish to pick an HTML color, go to HTML
Color Picker Page.
There are three primary colors in HTML webpages - Red, Green and Blue (RGB). All
the other colors displayed in a website are made of only these three primary colors.
The primary colors are blended with each other in varying amount to build millions
of colors. The saturation of primary colors (RGB) is defined in numeric values from
0 (lowest) to 255 (highest). If you want to get red color output, the numeric value
of 'R' (Red) will be 255, while each of 'G' (Green) and 'B' (Blue) will be 0. For
white, the numeric value for all three colors will be 255 and for black it will
be 0.
In HTML, the most common method to define colors is Hexadecimal system i.e.
with three pairs of two alpha-numeric characters starting with '#. In hexadecimal
system, 0 is defined by '00' and 255 is defined by 'FF'. Hence, the HTML color codes
are:
Red - #FF0000, Green - #00FF00 and Blue - #0000FF
Let's now create a few color codes!
HTML Color Codes
|
|
Color (R,G,B)
|
Color Code (#RRGGBB)
|
Color
|
|
255,0,0
|
#FF0000
|
RED
|
|
0,255,0
|
#00FF00
|
GREEN
|
|
0,0,255
|
#0000FF
|
BLUE
|
|
255,255,255
|
#FFFFFF
|
WHITE
|
|
0,0,0
|
#000000
|
BLACK
|
|
255,255,0
|
#FFFF00
|
YELLOW
|
Defining Colors in webpages
Defining Colors with Names
Colors are defined in three different styles in a webpage. The most simple is to
write the name of the color directly like style="background-color:Red;".
However, it is not possible to remember the name of many colors. Few HTML colors
names which you can use directly are:
|
Aqua
|
|
Black
|
|
|
Blue
|
|
Gray
|
|
|
Green
|
|
Lime
|
|
|
Maroon
|
|
Navy
|
|
|
Orange
|
|
Purple
|
|
|
Red
|
|
Silver
|
|
|
White
|
|
Yellow
|
|
Defining Colors with 'rgb' values
Second method to define HTML color in a webpage is to use the values of primary
colors which is represented as
rgb(RED, GREEN, BLUE) with range from 0 to
255 for each color. For example, Red is defined as
rgb(255,0,0).
However, I do not recommend to use this format because still there are many web
browsers which do not interpret 'rgb' values.
Defining Colors with Hexadecimal System
As already mentioned, the most common way to define HTML color is to use hexadecimal
system. It may look a little difficult at the beginning, but it is very flexible
and used widely.
Mostly, HTML color codes are used in defining font colors, background colors, border
colors, heading colors, link colors, etc. For most of these, you may define the
color by 'style' attribute of that tag. Here are some examples:
Good news is that you do not need to remember the color name or experiment with
color values or hexadecimal codes. There are plenty of software available which
allow you to select the color of your choice and get the hexadecimal code. We also
have a page dedicated for Picking HTML Color.