HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or HSLA values.
In HTML, a color can be specified by using a color name:
Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray
You can set the background color for HTML elements:
Hello World
Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti optio asperiores nobis incidunt, aut natus, nemo dolore exercitationem beatae facilis sed doloremque nam officiis ipsum laudantium dignissimos dolorem ex eum!
You can set the color of text:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
You can set the color of borders:
In HTML, colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA values.
The following three <div> elements have their background color set with RGB, HEX, and HSL values:
The following two <div> elements have their background color set with RGBA and HSLA values, which add an Alpha channel to the color (here we have 50% transparency):