Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.CSS uses color values to specify a color. Typically, these are used to set a color either for the foreground of an element (i.e., its text) or else for the background of the element. They can also be used to affect the color of borders and other decorative effects.
Color Names
In HTML, a color can be specified by using a color name:
Example -
Background Color
You can set the background color for HTML elements:
Example -
Text Color
You can set the color of text:
Example -
Border Color
You can set the color of the borders : -
Example -
Color Values
In HTML, colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA values:
Same as color name "DodgerBlue":
Same as color name "DodgerBlue", but 50% transparent:
Color Name
Hex Code
RGB
Decimal Code
RGB
Maroon
800000
12800
Red
ff0000
25500
Orange
ffA500
2551650
Yellow
ffff00
2552550
Olive
808000
1281280
Green
008000
01280
Purple
800080
1280128
Fuchsia
ff00ff
2550255
Lime
00ff00
02550
Teal
008080
0128128
Aqua
00ffff
0255255
Blue
0000ff
00255
Navy
000080
00128
Black
000000
000
Gray
808080
128128128
Silver
c0c0c0
192192192
White
ffffff
255255255
Css Color Chart - X11 Color Names
The colors in the following color chart represent the official X11 color names. Standardized by SVG 1.0, most of these colors are distributed with the X Windows System. These colors should be recognized by most modern browsers.