Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>example of external CSS</title>
<link href="color-inherit.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>We are learning color property of CSS</p>
<ul>
<li>we will learn color property of CSS in this section</li>
</ul>
</body>
</html>

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