RGB Colors in CSS

RGB colors can be specified in style rules by any of the methods listed in Table D-2.

Table D-2. Methods for specifying RGB colors

Method

Syntax

Example

Six-digit hexadecimal.

#RRGGBB

color: #0033FF

Three-digit RGB shorthand. This method may be used when each RGB value is double digits.

#RGB

(interpreted as #RRGGBB )

color: #03F

(interpreted as color: #0033FF)

Three decimal values.

rgb(n, n, n)

color: rgb(0,51,255)

Three percentage values (calculated as a percentage of 255).

rgb(%, %, %)

color: rgb(0%, 20%, 100%)

Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.