CSS color inherit

Color inherit

As we have seen in the previous table that color and inherit these are two values used for color property.We already have seen a few examples of using color value. We will see an example of using the inherit value of the color property.

Here is the css file (say color-inherit.css):

body {
color: teal
li {
color: #808000

Here is the html file (say color-inhrit.htm) to which the stylesheet above is applied:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>example of external CSS</title>
<link href="color-inherit.css" rel="stylesheet" type="text/css" />
<p>We are learning color property of CSS</p>
<li>we will learn color property of CSS in this section</li>

Here is how it will look:

In this example we can see that since it is not mentioned explicitly, color of text contained within p element is teal since it is the color of the body. But since it is explicitly mentioned, color of list item (li) is #808000.

Previous: CSS color units
Next: CSS User Interface

Follow us on Facebook and Twitter for latest update.