<color>

The <color> CSS data type represents a color. A <color> may also include an alpha-channel transparency value, indicating how the color should composite with its background.

A <color> can be defined in any of the following ways:

Using a keyword (such as blue or transparent). Using the RGB cubic-coordinate system (via the #-hexadecimal or the rgb() and rgba() functional notations). Using the HSL cylindrical-coordinate system (via the hsl() and hsla() functional notations).

Syntax

The <color> data type is specified using one of the options listed below.

Named Color

Named colors are case-insensitive identifiers that represent a specific color, such as red, blue, black, or lightseagreen.

Namergba functionLive
transparentrgba(0, 0, 0, 0)
transparent
alicebluergba(240, 248, 255, 1)
antiquewhitergba(250, 235, 215, 1)
aquargba(0, 255, 255, 1)
aquamarinergba(127, 255, 212, 1)
azurergba(240, 255, 255, 1)
beigergba(245, 245, 220, 1)
bisquergba(255, 228, 196, 1)
blackrgba(0, 0, 0, 1)
blanchedalmondrgba(255, 235, 205, 1)
bluergba(0, 0, 255, 1)
bluevioletrgba(138, 43, 226, 1)
brownrgba(165, 42, 42, 1)
burlywoodrgba(222, 184, 135, 1)
cadetbluergba(95, 158, 160, 1)
chartreusergba(127, 255, 0, 1)
chocolatergba(210, 105, 30, 1)
coralrgba(255, 127, 80, 1)
cornflowerbluergba(100, 149, 237, 1)
cornsilkrgba(255, 248, 220, 1)
crimsonrgba(220, 20, 60, 1)
cyanrgba(0, 255, 255, 1)
darkbluergba(0, 0, 139, 1)
darkcyanrgba(0, 139, 139, 1)
darkgoldenrodrgba(184, 134, 11, 1)
darkgrayrgba(169, 169, 169, 1)
darkgreenrgba(0, 100, 0, 1)
darkgreyrgba(169, 169, 169, 1)
darkkhakirgba(189, 183, 107, 1)
darkmagentargba(139, 0, 139, 1)
darkolivegreenrgba(85, 107, 47, 1)
darkorangergba(255, 140, 0, 1)
darkorchidrgba(153, 50, 204, 1)
darkredrgba(139, 0, 0, 1)
darksalmonrgba(233, 150, 122, 1)
darkseagreenrgba(143, 188, 143, 1)
darkslatebluergba(72, 61, 139, 1)
darkslategrayrgba(47, 79, 79, 1)
darkslategreyrgba(47, 79, 79, 1)
darkturquoisergba(0, 206, 209, 1)
darkvioletrgba(148, 0, 211, 1)
deeppinkrgba(255, 20, 147, 1)
deepskybluergba(0, 191, 255, 1)
dimgrayrgba(105, 105, 105, 1)
dimgreyrgba(105, 105, 105, 1)
dodgerbluergba(30, 144, 255, 1)
firebrickrgba(178, 34, 34, 1)
floralwhitergba(255, 250, 240, 1)
forestgreenrgba(34, 139, 34, 1)
fuchsiargba(255, 0, 255, 1)
gainsbororgba(220, 220, 220, 1)
ghostwhitergba(248, 248, 255, 1)
goldrgba(255, 215, 0, 1)
goldenrodrgba(218, 165, 32, 1)
grayrgba(128, 128, 128, 1)
greenrgba(0, 128, 0, 1)
greenyellowrgba(173, 255, 47, 1)
greyrgba(128, 128, 128, 1)
honeydewrgba(240, 255, 240, 1)
hotpinkrgba(255, 105, 180, 1)
indianredrgba(205, 92, 92, 1)
indigorgba(75, 0, 130, 1)
ivoryrgba(255, 255, 240, 1)
khakirgba(240, 230, 140, 1)
lavenderrgba(230, 230, 250, 1)
lavenderblushrgba(255, 240, 245, 1)
lawngreenrgba(124, 252, 0, 1)
lemonchiffonrgba(255, 250, 205, 1)
lightbluergba(173, 216, 230, 1)
lightcoralrgba(240, 128, 128, 1)
lightcyanrgba(224, 255, 255, 1)
lightgoldenrodyellowrgba(250, 250, 210, 1)
lightgrayrgba(211, 211, 211, 1)
lightgreenrgba(144, 238, 144, 1)
lightgreyrgba(211, 211, 211, 1)
lightpinkrgba(255, 182, 193, 1)
lightsalmonrgba(255, 160, 122, 1)
lightseagreenrgba(32, 178, 170, 1)
lightskybluergba(135, 206, 250, 1)
lightslategrayrgba(119, 136, 153, 1)
lightslategreyrgba(119, 136, 153, 1)
lightsteelbluergba(176, 196, 222, 1)
lightyellowrgba(255, 255, 224, 1)
limergba(0, 255, 0, 1)
limegreenrgba(50, 205, 50, 1)
linenrgba(250, 240, 230, 1)
magentargba(255, 0, 255, 1)
maroonrgba(128, 0, 0, 1)
mediumaquamarinergba(102, 205, 170, 1)
mediumbluergba(0, 0, 205, 1)
mediumorchidrgba(186, 85, 211, 1)
mediumpurplergba(147, 112, 219, 1)
mediumseagreenrgba(60, 179, 113, 1)
mediumslatebluergba(123, 104, 238, 1)
mediumspringgreenrgba(0, 250, 154, 1)
mediumturquoisergba(72, 209, 204, 1)
mediumvioletredrgba(199, 21, 133, 1)
midnightbluergba(25, 25, 112, 1)
mintcreamrgba(245, 255, 250, 1)
mistyrosergba(255, 228, 225, 1)
moccasinrgba(255, 228, 181, 1)
navajowhitergba(255, 222, 173, 1)
navyrgba(0, 0, 128, 1)
oldlacergba(253, 245, 230, 1)
olivergba(128, 128, 0, 1)
olivedrabrgba(107, 142, 35, 1)
orangergba(255, 165, 0, 1)
orangeredrgba(255, 69, 0, 1)
orchidrgba(218, 112, 214, 1)
palegoldenrodrgba(238, 232, 170, 1)
palegreenrgba(152, 251, 152, 1)
paleturquoisergba(175, 238, 238, 1)
palevioletredrgba(219, 112, 147, 1)
papayawhiprgba(255, 239, 213, 1)
peachpuffrgba(255, 218, 185, 1)
perurgba(205, 133, 63, 1)
pinkrgba(255, 192, 203, 1)
plumrgba(221, 160, 221, 1)
powderbluergba(176, 224, 230, 1)
purplergba(128, 0, 128, 1)
redrgba(255, 0, 0, 1)
rosybrownrgba(188, 143, 143, 1)
royalbluergba(65, 105, 225, 1)
saddlebrownrgba(139, 69, 19, 1)
salmonrgba(250, 128, 114, 1)
sandybrownrgba(244, 164, 96, 1)
seagreenrgba(46, 139, 87, 1)
seashellrgba(255, 245, 238, 1)
siennargba(160, 82, 45, 1)
silverrgba(192, 192, 192, 1)
skybluergba(135, 206, 235, 1)
slatebluergba(106, 90, 205, 1)
slategrayrgba(112, 128, 144, 1)
slategreyrgba(112, 128, 144, 1)
snowrgba(255, 250, 250, 1)
springgreenrgba(0, 255, 127, 1)
steelbluergba(70, 130, 180, 1)
tanrgba(210, 180, 140, 1)
tealrgba(0, 128, 128, 1)
thistlergba(216, 191, 216, 1)
tomatorgba(255, 99, 71, 1)
turquoisergba(64, 224, 208, 1)
violetrgba(238, 130, 238, 1)
wheatrgba(245, 222, 179, 1)
whitergba(255, 255, 255, 1)
whitesmokergba(245, 245, 245, 1)
yellowrgba(255, 255, 0, 1)
yellowgreenrgba(154, 205, 50, 1)

RGB Color Model

RGB colors can be expressed through both hexadecimal (prefixed with #) and functional (rgb(), rgba()) notations.

Syntax

  • hexadecimal: #RGB[A] or #RRGGBB[AA] R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0-9, A-F). A is optional. For example, #ff0000 is equivalent to #ff0000ff. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388.

  • rgb() or rgba() R (red), G (green), and B (blue) can be either <number>s or <percentage>s, where the number 255 corresponds to 100%. A (alpha) can be a <number> between 0 and 1, or a <percentage>, where the number 1 corresponds to 100% (full opacity).

HSL Color Model

The HSL color model defines a given color according to its hue, saturation, and lightness components. An optional alpha component represents the color's transparency.

Syntax

HSL colors are expressed through the functional hsl() and hsla() notations.

hsl() or hsla():hsl[a](H, S, L[, A])

  • H (hue) is an <angle> of the color circle given in degs, rads, grads. When written as a unitless <number>, it is interpreted as degrees. By definition, red=0deg=360deg, with the other colors spread around the circle, so green=120deg, blue=240deg, etc.
  • S (saturation) and L (lightness) are percentages. 100% saturation is completely saturated, while 0% is completely unsaturated (gray). 100% lightness is white, 0% lightness is black, and 50% lightness is "normal".
  • A (alpha) can be a <number> between 0 and 1, or a <percentage>, where the number 1 corresponds to 100% (full opacity).

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.