Affiliate link

CSS - Colors

Color values are defined in multiple formats.

CSS color - Predefined color names

The color property value can be defined with color name, such as black, white, red, green, or skyblue.

color: red;


<p style="color: red;">Red text</p>

Code Result

Affiliate link

CSS color - HEX

Hexadecimal (HEX) color value is defined in this format, #RRGGBB. RR is red, GG is green, and BB is blue color value.

<p style="color: #FF0000;">Red text</p>
<p style="color: #00FF00;">Green text</p>
<p style="color: #0000FF;">Blue text</p>

Code Result

CSS color - RGB

RGB color values are defined in numbers start from 0 to 255. The format is RGB(RRR, GGG, BBB) and is case insensitive.

color: RGB(255, 0, 0);

<p style="color: RGB(255, 0, 0);">Red text</p>
<p style="color: rgb(0, 255, 00);">Green text</p>
<p style="color: Rgb(0, 0, 255);">Blue text</p>

Code Result

CSS color - RGBA

RGBA stands for Red, Green, Blue, and Alpha. Alpha channel allows you to define the opacity for the color.

Alpha channel value is defined with decimal values start 0.0 to 1.0.
0 - Transparent.
1 - Not transparent.

<p style="color: red;">Red text</p>

Code Result

CSS color - HSL

HSL stands for hue, saturation, and lightness.

Hue is a degree value on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue.
Saturation is defined with percentage value. 0% is shade of gray. 100% is the full color.
Lightness is also defined with percentage value. 0% is black. 100% is white.

<p style="color: red;">Red text</p>

Code Result

CSS color - HSLA

HSL stands for Hue, Saturation, Lightness, and Alpha

color: red;

<p style="color: red;">Red text</p>

Code Result

Affiliate link
Affiliate link
Affiliate link
Advertisment
WP Engine
Get Surfshark VPN
rocket.net