CSS allows us to set colors for elements in different ways. We can use color names, HEX codes, RGB/RGBA values, and HSL/HSLA formats.
CSS recognizes more than 140 predefined color names, such as 'red', 'blue', 'green'. These provide a quick and easily understandable solution.
HEX codes contain the red, green, and blue components of a color. Format: #RRGGBB, where each component is a hexadecimal number between 00 and FF.
The RGB color model defines color by mixing red, green, and blue. RGBA adds an alpha channel that defines transparency.
The HSL (Hue, Saturation, Lightness) model defines color based on hue, saturation, and lightness. HSLA also includes an alpha channel for transparency.
The following squares contain the color name, HEX code, and RGB code.
Red
#FF0000
rgb(255, 0, 0)
Green
#00FF00
rgb(0, 255, 0)
Blue
#0000FF
rgb(0, 0, 255)
Purple
#800080
rgb(128, 0, 128)
Orange
#FFA500
rgb(255, 165, 0)
Cyan
#00FFFF
rgb(0, 255, 255)
Pink
#FFC0CB
rgb(255, 192, 203)
Yellow
#FFFF00
rgb(255, 255, 0)
The following examples show how we can achieve the same color using different formats.
The correct choice of colors is important for the appearance of websites and also for accessibility.
Please sign in to ask Lara about CSS Colors.
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.