How to use color codes in HTML & CSS?
Using CSS color codes we can set the color of web site background, color of cells in tables, color of text, color of table headers and much more.
Using CSS color codes for web site background color:
body {background:#80BFFF;} |
Using CSS color codes for setting font/text color in CSS:
Using CSS color codes for table background color in CSS:
#table{ background:#80BFFF;} .table{background:#80BFFF;} |
Using CSS color code for link color in CSS:
a:link{color:#80BFFF;} a:hover{color:DarkBlue;} a:visited{color:#80BFFF;} a:active{color:Blue;} |
How CSS Color Codes are Defined
CSS & HTML colors are defined using a hexadecimal notation for the combination of Red, Green, and Blue color values (RGB). The lowest value that can be given to one of the light sources is 0 (hex 00). The highest value is 255 (hex FF).
Hex values are written as 3 double digit numbers (000000), starting with a # sign. So you are wondering "Does this weird combination of letters and numbers have any meaning?" Well the answer is "Yes" and this is how it goes:)
Color Examples
| Color |
Color HEX |
Color RGB |
| |
#000000 |
rgb(0,0,0) |
| |
#FF0000 |
rgb(255,0,0) |
| |
#00FF00 |
rgb(0,255,0) |
| |
#0000FF |
rgb(0,0,255) |
| |
#FFFF00 |
rgb(255,255,0) |
| |
#00FFFF |
rgb(0,255,255) |
| |
#FF00FF |
rgb(255,0,255) |
| |
#C0C0C0 |
rgb(192,192,192) |
| |
#FFFFFF |
rgb(255,255,255) |
Millions of Different Colors
The combination of Red, Green, and Blue (256 x 256 x 256) values from 0 to 255, gives
more than 16 million different colors.
|