CSS Colors

You can assign Hexadecimal colors, RGB colors, RGBA colors, HSL colors, HSLA colors and color names.

Hexadecimal colors in CSS

A hexadecimal color code starts with a hash(#) and followed by 6 alpha numeric value. Like #000000 stands for Black color and #FFFFFF stands for White color. The First 2 letter stands for Red, next 2 for Green and last 2 letter for Blue color. The range is from Zero (0) to F. The Hexadecimal color values are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F total 16 digits.

Click here to know more about Hexadecimal colors.

p { background-color:#CCCCCC; } 

RGB colors in CSS

RGB stands for Red, Green and Blue. The HTML format for a RGB value is rgb (Value of RED, Value of GREEN, Value of BLUE). The value range are from 0 to 255. rgb(0,0,0) stand for Black color and rgb(255,255,255) stands for White color.

Click here to know more about RGB colors.

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

RGBA colors in CSS

In RGBA color A statds for alpha property of background color. The value starts form 0.0 and ends at 1.0. It works in all mejor browsers including IE9+.

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

HSL Colors

HSL stands for hue, saturation and lightness. hue accept value from 0 to 360 where saturation and lightness accept 0 to 100%.   

p { background-color:hsl(240,25%,50%); } 

HSLA Colors

Same as RGBA, here A stands for alpha.
p { background-color:hsla(240,25%,50%,0.5); } 

Colors Names

You can also used browser supported color names like red, green, blue, black, white etc.
p { background-color:'blue'; } 

comments powered by Disqus