HTML CSS examples for CSS Property:color
The color CSS property sets the color for an element's text content.
The following table summarizes the color property.
Item | Value |
---|---|
Default value: | Depends on the browser |
Applies to: | All elements |
Inherited: | Yes |
Animatable: | Yes. |
The syntax of the property is as follows:
color: color | initial | inherit
The following table describes the values of this property.
Value | Description |
---|---|
color | any valid CSS Color Values. |
initial | Sets this property to its default value. |
inherit | take the value of its parent element color property. |
The example below shows the color property.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of CSS color property</title> <style type="text/css"> body {<!-- w ww .j a v a 2 s.co m--> color: red; } h1 { color: #00ff00; } p { color: rgb(0,0,255); } </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> <div> The default color for the text content is defined in the body selector. </div> </body> </html>