CSS - color


Advertisements


Description

The color property sets the foreground color of an element (typically, the color of the text).

Possible Values

  • color − should be any valid color value.

Applies to

All the HTML elements.

DOM Syntax

object.style.color = "#a1a1a1";

Example

Here is the example which shows effect of this property −

<html>
   <head>
   </head>
   <body>
      <h2 style="color:olive;">
      This text will have olive color.
      </h2>
      
      <p style="color:#3300CC">
      This text will have blue color.
      </p>
      
      <div style="color:rgb(224,37,197);">
      This text will have pink color.
      </div>
   </body>
</html> 

This will produce following result −



Advertisements