CSS Color

tutorial and example
tutorial and example

In HTML CSS uses color values to specify a color. You can specify the Colors in various formats like RGB, HEX, HSL, RGBA, and HSLA values.

The given following table will help you to understand the color format of CSS.

Format Syntax Example
Hex Code #800000 p{color: #800000;}
Short Hex Code #RGB p{color:#6A7;}
RGB % rgb(rrr%,ggg%,bbb%) p{color:rgb(50%,50%,50%);}
Keyword red, black etc. p{color:green;}

Text color

If you want to change the color of text then set the color of text.

Example

Try Now

Border Color

If you want to change the border color of text then set the color of text.

Try Now

CSS Colors- Hex Codes

In Hex codes there are 6 digits to represent the color. Each hexadecimal code will be used within hash ‘#’ sign .

There are following 6 digits values of Hex Code in detail.

  • The first two digits represents red value(RR).
  • The second two digits represents green value(GG).
  • The third two digits represents blue value(BB).

The following table will help you to implement the Hexadecimal notation:

Color Name Color HEX
Black #000000
Red #FF0000
Green #00FF00
Blue #0000FF etc.

Let us see an example of CSS color-hex codes:

Try Now

CSS Colors- RGB Values

In CSS Color, RGB values are represented by rgb( ) property. It takes three values red, green and blue. The value can be an integer between 0 and 225 or a percentage.

NOTE: There are various browser not supported in rgb ( ) property of color.

The following table will help you to implement the Hexadecimal notation:

Color Name RGB Values
Black rgb(0,0,0)
Red rgb(255,0,0)
Green rgb(0,225,0)
Blue rgb(0,0,225) etc.

Let us see an example of CSS color-RGB values:

Try Now

There are various colors code that are given below:

CSS Color 1