Advertisement
Google Ad Slot: content-top
CSS Color
In CSS, colors can be applied to elements in various ways using different color formats. Here’s an overview of how colors are specified and used in CSS.
Currently Active Property:
Color Formats in CSS (Color Values)
| Color Format | Description |
|---|---|
| Named Colors | CSS provides a set of named colors that you can use directly without needing to define the color value. |
| Hexadecimal Colors | Hexadecimal colors are defined using a # followed by either 3 or 6 hexadecimal characters (0-9, A-F). The first two digits represent red, the next two represent green, and the last two represent blue. |
| RGB Colors | RGB colors are specified with the rgb() function, which defines colors by setting red, green, and blue channels with values between 0 and 255. |
| RGBA Colors | RGBA is the same as RGB but includes an alpha channel that controls the transparency of the color. The alpha value is a number between 0 (completely transparent) and 1 (completely opaque). |
| HSL Colors | HSL stands for Hue, Saturation, and Lightness. The hsl() function is another way to represent colors: |
| HSLA Colors | HSLA is the same as HSL but includes an alpha channel to control the transparency. |
| CurrentColor Keyword | currentColor is a special keyword that uses the current value of the color property. |
| Transparent Keyword | The transparent keyword sets a fully transparent color. It's often used as a fallback or default value in CSS backgrounds or borders. |
Named Colors:
CSS provides a set of named colors that you can use directly without needing to define the color value.
Hexadecimal Colors:
Hexadecimal colors are defined using a # followed by either 3 or 6 hexadecimal characters (0-9, A-F). The first two digits represent red, the next two represent green, and the last two represent blue.
RGB Colors:
RGB colors are specified with the rgb() function, which defines colors by setting red, green, and blue channels with values between 0 and 255
RGBA Colors:
RGBA is the same as RGB but includes an alpha channel that controls the transparency of the color. The alpha value is a number between 0 (completely transparent) and 1 (completely opaque).
HSL Colors:
HSL stands for Hue, Saturation, and Lightness. The hsl() function is another way to represent colors:
- Hue: An angle from 0 to 360 (the color on the color wheel).
- Saturation: A percentage (
0%is grey,100%is full color). - Lightness: A percentage (
0%is black,100%is white).
HSLA Colors:
HSLA is the same as HSL but includes an alpha channel to control the transparency.
CurrentColor Keyword:
currentColor is a special keyword that uses the current value of the color property.
Transparent Keyword:
The transparent keyword sets a fully transparent color. It's often used as a fallback or default value in CSS backgrounds or borders.