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
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework