How to Use the CSS Property Value Inherit

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.

  1. Add the rule for p 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>
  2. In the body, place the em tag around the word inherit.
    <body>
    	<p>Even the word <em>inherit</em> isn't italicized.</p>
    	</body>
    </html>
  3. The final markup will look like this:
    <!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>
  4. The rendered text will look like this:
    Inherit

Author: Chris Minnick

Chris Minnick, the co-founder of WatzThis?, has overseen the development of hundreds of web and mobile projects for customers from small businesses to some of the world’s largest companies. A prolific writer, Chris has authored and co-authored books and articles on a wide range of Internet-related topics including HTML, CSS, mobile apps, e-commerce, e-business, Web design, XML, and application servers. His published books include Adventures in Coding, JavaScript For Kids For Dummies, Writing Computer Code, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW E-Commerce Designer Certification Bible, and XHTML.

About Webucator

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, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.