CSS Color
Advertisements
CSS Color
CSS uses Hexadecimal or Numerical values to specify a color. These are used to set the color of the background or foreground of an Html element.
Colors in CSS can be specified in various formats. Following table tells you all possible formats:
Format | Syntax | Example |
---|---|---|
Hex Code | #RRGGBB | p {color:#FF0000;} |
Short Hex Code | #RGB | p {color:#6A7;} |
RGB % | rgb(rrr%,ggg%,bbb%) | p{color:rgb(50%,50%,50%);} |
RGB Absolute | rgb(rrr,ggg,bbb) | p {color:rgb(0,0,255);} |
keyword | aqua, black, etc. | p {color:teal;} |
These formats are explained in more detail in the following sections:
CSS Colors - Hex Codes
- A hexadecimal is a 6 digit representation of a color.
- First two digits(RR) represent a red value.
- Next two digits(GG) represent a green value.
- Last two digits(BB) represent a blue value.
- A hexadecimal value can be taken from any graphics software like Adobe Photoshop, Jasc Paintshop Pro or even using Advanced Paint Brush.
- Each hexadecimal code will be preceded by a hash sign #.
- Examples to use Hexadecimal notation. #66AA77, #4488DD
Syntax
background: #FFF000;
CSS Colors - Short Hex Codes
- This is a shorter form of the six-digit notation. In this format, each digit is replicated to arrive at an equivalent six-digit value; For example: #6A7 becomes #66AA77.
- A hexadecimal value can be taken from any graphics software like Adobe Photoshop, Jasc Paintshop Pro or even using Advanced Paint Brush.
- Each hexadecimal code will be preceded by a pound or hash sign #.
- Examples to use Hexadecimal notation. #6A7, #48D
Syntax
background: #FFF;
CSS Colors - RGB Values
This color value is specified using the rgb( ) property. This property takes three values, one each for red, green, and blue. The value can be an integer between 0 and 255 or a percentage.
Note: All the browsers does not support rgb() property of color so it is recommended not to use it.
Syntax
background:rgb(142,54,76);
Google Advertisment