Many properties take the value inherit
. This specifies that the property value should be inherited from the parent element. If such a property is left undefined, the implicit
value is inherit
. The following three steps show how to use the CSS property value inherit
.
Take our Introduction to CSS Training course for free.
See the Course Outline and Registerp
to set the font-style
of paragraphs to none
, which means plain, non-italicized text. Add the rule for em
to set the font-style
for emphasized text, which is usually italic, to inherit
. This means that, in the HTML below the CSS (step 2), the em
tag will inherit the none
value from the containing p
tag. Also set the text-decoration
property to underline
so you can still see that the tag's content is emphasized:<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Inherit</title>
<style>
p {
font-style: none;
}
em {
font-style: inherit;
text-decoration: underline;
}
</style>
</head>
<html>
em
tag around the word inherit
.<body>
<p>Even the word <em>inherit</em> isn't italicized.</p>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Inherit</title>
<style>
p {
font-style: none;
}
em {
font-style: inherit;
text-decoration: underline;
}
</style>
</head>
<body>
<p>Even the word <em>inherit</em> isn't italicized.</p>
</body>
</html>
The rendered text will look like this:
Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, XML, Windows, Java, Adobe, HTML5, JavaScript, Angular, and much more. Check out our complete course catalog.