Latest web development tutorials

CSS legal color values

CSS Colors

CSS colors can be specified by the following method:

  • Hexadecimal color
  • RGB color
  • RGBA color
  • HSL color
  • HSLA color
  • Predefined / cross-browser color names

Hexadecimal color

All major browsers support hexadecimal color value.

Specify a hexadecimal color of its components are: #RRGGBB, where the RR (red), GG (green) and BB (blue). All values ​​must be between 0 and FF.

<P example, # 0000FF value is rendered as blue, blue as the highest value of the composition (FF) and others set to zero.

Examples

p
{
background-color:#ff0000;
}

try it"


RGB color

RGB color values ​​are supported in all major browsers.

RGB color value specifies: RGB (red, green, blue). The brightness of each parameter (red, green, and blue) color definitions can be an integer between 0 and 255, or a percentage value and between (from 0% to 100%).

E.g., RGB (0,0,255) value is rendered as blue because the blue parameter is set to the highest value (255) while the other is set to 0.

In addition, the same color following values ​​are defined: RGB (0,0,255), RGB (0%, 0%, 100%).

Examples

p
{
background-color:rgb(255,0,0);
}

try it"


RGBA color

RGBA color values ​​are IE9, Firefox3 +, Chrome, Safari, and Opera10 + support.

RGBA color values ​​are RGB color values ​​extending alpha channel - the specified object transparency.

RGBA color values ​​specified: RGBA (red, green, blue, alpha). Alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque) parameters.

Examples

p
{
background-color:rgba(255,0,0,0.5);
}

try it"


HSL color

IE9, Firefox, Chrome, Safari, and Opera 10+. Support HSL color values.

HSL representative of hue, saturation, and brightness - Use color cylindrical coordinates.

HSL color values ​​specified: HSL (hue, saturation, brightness).

Hue is a degree on the color wheel (from 0-360) -0 (or 360) is red, 120 green, 240 blue. Saturation is a percentage; 0% and 100% of the mean gray shadow, full color. Brightness is also a percentage; 0% is black, 100% is white.

Examples

p
{
background-color:hsl(120,65%,75%);
}

try it"


HSLA color

HSLA color values ​​are IE9, Firefox3 +, Chrome, Safari, and Opera10 +. Support.

HSLA color values ​​are an extension of HSL color values ​​with an alpha channel - the transparency of the specified object.

Specifies HSLA color values: HSLA (hue, saturation, brightness, α), α is the opacity Alpha parameter definition. Alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque) parameters.

Examples

p
{
background-color:hsla(120,65%,75%,0.3);
}

try it"


Predefined / cross-browser color names

147 is in HTML and CSS color specification predefined color name. You can see our predefined color name table .