The discussion on CSS colors might sound like a trivial subject however that’s actually far from the truth. Six Revisions author Jacob Gube has written a detailed explanation on different methods to declare CSS colors which are:
- Hexadecimal notation – Hex color code start with hash (#) and followed with 3 characters or six characters of number, alphabet, or combination of number and alphabet.
- RGB – RGB stands for Red, Green, Blue. Minimum decimal value is 0 and maximum decimal value is 255.
- RGBA – Similar to RGB. The additional “A” (alpha) is for specifying the level of transparency of your color. Value of alpha can be set between 0 to 1.
- HSL – Stands for Hue, Saturation and Lightness. The HSL color notation is an alternative to the RGB color notation. It was introduced to CSS with the idea that it’s more intuitive to learn compared to the RGB color system.
- HSLA – Like in RGBA, the A represents the alpha value for transparency.
- Color keywords – Basic color names like
blue
,maroon
,black
andwhite
. In CSS3, the number of keywords were extended to include fancy color names likeroyalblue
andkhaki
.
Hit button below to read the detailed explanation.