CSS: RGB Color

By Xah Lee. Date: . Last updated: .

Hexadecimal Syntax

The RGB color model uses 3 values, for {Red, Green, Blue}, each with a value range from 0 to 255, in 2 Hexadecimal digits.

p {
 background-color: #ffd700;
}
background-color: gold;
background-color: #ffd700;

Three digits Syntax Shortcut

if there are only 3 digits, it means doubling each digit.

p {
 background-color: #fd0;
}

/* is equivalent to */

p {
 background-color: #ffdd00;
}
background-color: #fd0;
background-color: #ffdd00;

RGB color function

CSS Color