CSS: RGB Color

By Xah Lee. Date: . Last updated: .

RGB 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 { color: #ffc0cb }

〔see Binary/Hexadecimal Converter

RGB Hexadecimal Syntax Shortcut

When using hexadecimal, if digit for each value are repeated, it can be abbreviated to just 3 hexadecimal digits. Like this:

color: #0f7

same as

color: #00ff77

RGB Integer Syntax

RGB color by integer, 0 to 255

p { color: rgb(255, 192, 203) }

RGB Percent Syntax

p { color: rgb(100%, 75%, 79%) }

Opacity RGB Syntax

rgba(red, green, blue, opacity)

Example

p.x { color: rgb(255, 192, 203, 0.5) }
p.y { color: rgb(100%, 75%, 79%, 0.5) }

CSS Color