CSS color is used to set the color of an HTML elements content in web pages. HTML content color can be in hex format, rbga format and color names etc.
Syntax
1 |
color: enter color code here; |
Example
Test it Live
1 2 3 4 5 6 |
<style> p.mycolor{ color:green; } </style> <p class="mycolor">This is the HTML paragraph. We have given color to it. The color is green.</p> |
Output
This is the HTML paragraph. We have given color to it. The color is green.
CSS color values list
The values and description of this property is used to specify the color of content inside web document. You should also see CSS background-color.
Sr. No. | value | Description |
---|---|---|
1 | hex color codes | Used to give color code in hex value format for the content. The value for this can be #fff, #000 etc. |
2 | rbga color codes | Used to give color code of content in rbga() format. The value for this can be rgba(255, 0, 0, 0.48), rgba(111, 66, 66, 0.48) etc. |
3 | color name | Used to give color name to apply color to web content. The value for this can be red, blue etc. |
4 | transparent | Used to make a transparent color of an HTML element content. The value for this is transparent. |
5 | initial | Used to define as the property initial value. |
6 | inherit | Used to define the computed value of property on the elements parent. |
7 | unset | Used to set all the properties to their parent value if inheritable. |
CSS color rgba()
In this example we use color with color value as rgba format.
Test it Live
1 2 3 4 5 6 |
<style> p.mycolor-rgba{ color:rgba(0, 137, 255, 0.67); } </style> <p class="mycolor-rgba">This is my paragraph to show the the CSS color in rgba() format.</p> |
Output
This is my paragraph to show the the CSS color in rgba() format.