News & UpdatesProgrammingWeb programming Store My Projects
Links
Affiliates

CSS Tutorial – 10 – Colors

CSS tutorials

In CSS, there are five different ways to specify a color.

Named and hexadecimal notations

The first two are the same as in HTML: named and hexadecimal colors.

h1 { color: red; }
h1 { color: #FF0000; }

Short hexadecimal notation

There is also a short hexadecimal notation. This notation can be converted to hexadecimal by duplicating each digit.

h1 { color: #F00; }

Functional notation

Then there is a functional notation where each red-green-blue intensity value can be specified as either a value between 0 and 255 or as a percentage.

h1 { color: rgb(255,0,0); }
h1 { color: rgb(100%,0%,0%); }
Recommended additional reading:
Sams - Teach Yourself HTML and CSS in 24 Hours