Using CSS color Property
CSS color property is also one of the most commonly used css property for changing the color of text inside elements. It defined the foreground color used for element’s text content.
Color value can be defined in following different ways
color: red; // A CSS predefined color.
color: #0f0; // 3-character dash notation.
color: #00ff00; // 6-character dash notation.
color: rgba( 34, 12, 64, 0.3); // functional notation with opacity
color: currentColor; // color's value of its direct ancestor.
color: inherit;
The value of color is inherited from its ancestors, so if we don’t define a color for some element, it will inherit the color value from its parent element.
Example: To change the link color of an anchor element
a { color: #FF0000; } /* Red color */
Same Red color can be assigned in other different formats as well
a { color: red; } a { color: #F00; } a { color: #FF0000; } a { color: rgb(255, 0, 0); } a { color: rgba(255, 0, 0, 1.0); } /* opacity is 1 */
You can refer to following reference for all predefined color data type values