CSS (Cascading Style Sheets) supports a variety of color formats, including named colors, hexadecimal colors, RGB (Red, Green, Blue) values, RGBA (RGB with an alpha channel for transparency), HSL (Hue, Saturation, Lightness) values, and HSLA (HSL with an alpha channel).
Here's a brief overview of each:
1. Named Colors: CSS provides a set of predefined color names, such as "red", "blue", "green", etc.
Example: color: red;
2. Hexadecimal Colors: Represented as a six-digit code preceded by a hash (#). Each pair of digits represents the intensity of the red, green, and blue components, respectively.
Example: color: #ff0000; (red)
3. RGB Colors: Represented as `rgb(red, green, blue)`, where each component is an integer between 0 and 255.
Example: color: rgb(255, 0, 0); (red)
4. RGBA Colors: Similar to RGB, but with an additional alpha channel representing transparency, specified as a value between 0 and 1.
Example: color: rgba(255, 0, 0, 0.5); (semi-transparent red)
5. HSL Colors: Represented as `hsl(hue, saturation%, lightness%)`, where hue is an angle between 0 and 360, and saturation and lightness are percentages.
Example: color: hsl(0, 100%, 50%); (red)
6. HSLA Colors: Similar to HSL, but with an additional alpha channel for transparency.
Example: color: hsla(0, 100%, 50%, 0.5); (semi-transparent red)
These color formats can be used in various CSS properties such as `color`, `background-color`, `border-color`, and more.
Here are examples of each color format used in CSS:
1. Named Color: color: red;
2. Hexadecimal Color: color: #ff0000; /* Red */
3. RGB Color: color: rgb(255, 0, 0); /* Red */
4. RGBA Color: color: rgba(255, 0, 0, 0.5); /* Semi-transparent red */
5. HSL Color: color: hsl(0, 100%, 50%); /* Red */
6. HSLA Color: color: hsla(0, 100%, 50%, 0.5); /* Semi-transparent red */
You can replace the color values in these examples with any other color values or adjust the alpha channel for transparency as needed.