{"id":4168,"date":"2015-05-11T12:15:52","date_gmt":"2015-05-11T09:15:52","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=4168"},"modified":"2018-01-08T14:38:51","modified_gmt":"2018-01-08T12:38:51","slug":"css-inheritance-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/","title":{"rendered":"CSS Inheritance Example"},"content":{"rendered":"<p>In this example, we&#8217;ll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites.<\/p>\n<p>It is <code>inherit<\/code>. Before we go straight into that, know the following:<\/p>\n<p>Each element in HTML is part of a &#8216;tree&#8217;, and every element (except the initial <code>html<\/code> element) has a parent element that encloses it. <\/p>\n<p>Whatever styles applied to the parent element can be applied to the elements inside it if the properties are inherited.<\/p>\n<p>Below, we&#8217;re going to have a look at several cases of inheritance property.<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;nAkUl5IbAjqlXSla&#8217;]<\/p>\n<h2> 1. Prerequisites <\/h2>\n<p>Create a <code>html<\/code> document with the basic syntax inside like this:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;CSS Inheritance Property Value&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n\t&lt;!-- STYLE SECTION --&gt;\r\n\t&lt;style type=\"text\/css\"&gt;\r\n\r\n  \t&lt;\/style&gt;\r\n\r\n\t&lt;!-- HTML SECTION --&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In the html section, we&#8217;ll add some elements to show their relation to other elements and understand when they automatically inherit property values from their parents and when not. <\/p>\n<p>Lets first see a basic application of the <code>inherit<\/code> property value.<\/p>\n<h2> 2. Basic Application of Inherit <\/h2>\n<p>The inherit property value is at some cases automatically applied to child elements, and at other cases needs to be applied manually.<\/p>\n<h3> 2.1 Automatic Inheritance <\/h3>\n<p>I always tend to give the <code>body<\/code> element a custom font-family so that all elements have the same font applied. <\/p>\n<p>In other words, all elements <code>inherit<\/code> the font-family property from the body parent.<\/p>\n<p>Look at the code below:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION --&gt;\r\n\t\r\n&lt;div class=\"parent\"&gt; This is a &lt;span&gt;parent&lt;\/span&gt; element.\r\n\r\n&lt;div class=\"child\"&gt;This is a &lt;span&gt;child&lt;\/span&gt; element.\r\n\r\n&lt;p&gt;This is a &lt;a href=\"#\"&gt;link&lt;\/a&gt; inside a paragraph&lt;\/p&gt;\r\n\r\n&lt;\/div&gt;&lt;!-- end child element --&gt;\r\n&lt;\/div&gt;&lt;!-- end parent element --&gt;\r\n<\/pre>\n<p>I have added a parent division and inside that two children, another div and a paragraph.<\/p>\n<p>The classes given are so that we can give attributes to parent and see the results to children.<\/p>\n<p>Now below look at the some initial properties I&#8217;ve given to these elements:<\/p>\n<pre class=\"brush:css\">\r\n&lt;!-- STYLE SECTION --&gt;\r\n\r\n&lt;style type=\"text\/css\"&gt;\r\n\r\nbody {\r\n\tfont-family: \"Aller\",\"sans-serif\";\r\n}\r\n\r\n.parent {\r\n\twidth: 15em;\r\n\theight: 5em;\r\n\tcolor: gray;\r\n\tfont-weight: bold;\r\n\tfont-size: 2em;\r\n\tborder: 0.1em solid red;\r\n}\r\n\r\n.parent span {\r\n\tcolor: green;\r\n}\r\n\r\n&lt;\/style&gt;\r\n<\/pre>\n<p>Now to see what what properties have been inherited look at the browser view:<br \/>\n<figure id=\"attachment_4190\" aria-describedby=\"caption-attachment-4190\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit1.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit1.jpg\" alt=\"Initial Test on Inheritance\" width=\"800\" height=\"220\" class=\"size-full wp-image-4190\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit1.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit1-300x83.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4190\" class=\"wp-caption-text\">Initial Test on Inheritance<\/figcaption><\/figure><\/p>\n<p>Seen this result, we can state that the following elements get inherited properties automatically:<\/p>\n<p>1. All elements <code>inherit<\/code> the <code>font-family<\/code> property from a higher level parent, which is body.<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;Notice all three lines have the same font applied.<\/p>\n<p>2. All child elements <code>inherit<\/code> the <code>color<\/code> (font-color) from the parent element.<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;Notice all the lines have the same gray color applied (except span and link).<\/p>\n<p>3. The parent <code>span<\/code> element is set to have a green color, but also the child span gets a green font-color.<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;So the child inherits from parent automatically span elements too.<\/p>\n<p>Think everything is inherited?<\/p>\n<p>The <code>a<\/code> anchor element has not been styled, but it shows in blue and underlined. That&#8217;s because these two properties are set to be default ones for all anchor tags over the page.<\/p>\n<p>The link did not inherit the color from its parent element, because it has a different color (blue). Look at the border. It has only been applied to the parent element, and it shows only there. That&#8217;s why we sometimes need to apply inheritance manually to make these element fit the desired view.<\/p>\n<h3> 2.1 Forced\/Applied Inheritance <\/h3>\n<p>Simple as that, refer to the <code>.child<\/code> class and inherit the <code>border<\/code> for the child and <code>color<\/code> property from parent for the link:<\/p>\n<pre class=\"brush:css\">\r\n.parent a {\t\t\t\t\/* you can refer even to the child class *\/\r\n\tcolor: inherit;\t\t\/* inherited color from the parent class *\/\r\n}\r\n\r\n.child {\t\t\t\t\t\r\n\tborder: inherit;\t\/* inherited the border attributes to child and elements inside *\/\r\n}\r\n<\/pre>\n<p>The browser view:<br \/>\n<figure id=\"attachment_4201\" aria-describedby=\"caption-attachment-4201\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit2.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit2.jpg\" alt=\"Inherit Value Applied to Color and Border\" width=\"800\" height=\"220\" class=\"size-full wp-image-4201\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit2.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit2-300x83.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4201\" class=\"wp-caption-text\">Inherit Value Applied to Color and Border<\/figcaption><\/figure><\/p>\n<p>Notice that:<\/p>\n<p>1. The link became the <strong>same color as the parent<\/strong> (its parent can be considered both the parent class element and the child class element, becuase the paragraph is nested inside the child element).<\/p>\n<p>2. The border attributes got applied to the child element which contains another element inside, that&#8217;s why you see the second smaller red border wrapping both the second and third line (child and paragraph elements).<\/p>\n<p>That was a basic application of the inherit property value. Now let&#8217;s see other cases and examples.<\/p>\n<h2> 3. Cases and Examples <\/h2>\n<p>Here we look at some essential cases and examples where we can use the <code>inherit<\/code> property value.<\/p>\n<h3> 3.1 Size and Background Inheritance <\/h3>\n<p>Change the html code to accommodate the following image and text elements:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;div class=\"parent-image\"&gt;\r\n&lt;h4&gt;Everything you can imagine is real.&lt;br&gt;-The Parent Image&lt;\/h4&gt;\r\n\r\n&lt;div class=\"child-image\"&gt;\r\n&lt;h4&gt;Glad to have looked after you.&lt;br&gt;-The Child Image&lt;\/h4&gt;\t\r\n\r\n&lt;\/div&gt;&lt;!-- end child image --&gt;\r\n&lt;\/div&gt;&lt;!-- end parent image --&gt;\r\n<\/pre>\n<p>and the css code accordingly:<\/p>\n<pre class=\"brush:css\">\r\n.parent-image  {\r\n\twidth: 30em;\r\n\theight: 30em;\r\n\tbackground-image: url(\"images\/img1.jpg\");\r\n\tbackground-repeat: no-repeat;\r\n}\r\n\r\n.parent-image h4 {\r\n\tcolor: gray;\r\n\ttext-align: center;\r\n\tline-height: 1.5em;\t\t\/* vertically align text in the center *\/\r\n\tpadding: 1em;\t\t\t\/* just to differentiate the two elements *\/\r\n}\r\n\r\n.child-image {\r\n\twidth: inherit;\t\t\t\t\t\/* inherited width *\/\r\n\theight: inherit;\t\t\t\t\/* inherited height *\/\r\n\tbackground-image: inherit;\t\t\/* inherited background *\/\r\n\tbackground-repeat: inherit;\r\n}\r\n<\/pre>\n<p>Now notice the child element inherits the background and size attributes from the parent:<br \/>\n<figure id=\"attachment_4210\" aria-describedby=\"caption-attachment-4210\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit3.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit3.jpg\" alt=\"Size and Background Values Inherited\" width=\"800\" height=\"220\" class=\"size-full wp-image-4210\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit3.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit3-300x83.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4210\" class=\"wp-caption-text\">Size and Background Values Inherited<\/figcaption><\/figure><\/p>\n<h3> 3.2 Inheritance Manipulations <\/h3>\n<p>You can also use the inherit property value to avoid inheritance from one level higher parent.<\/p>\n<p>Look at the codes below: <\/p>\n<p>HTML<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION --&gt;\r\n\r\n&lt;div class=\"parent\"&gt;\r\n\r\n&lt;div class=\"child1\"&gt;\r\n&lt;h3&gt;A title here&lt;\/h3&gt;\r\n&lt;p&gt;A paragraph text here&lt;\/p&gt;\r\n&lt;button&gt;A button here&lt;\/button&gt;\r\n&lt;\/div&gt;&lt;!-- end child1 element --&gt;\r\n\r\n&lt;div class=\"child2\"&gt;\r\n&lt;h3&gt;A title here&lt;\/h3&gt;\r\n&lt;p&gt;A paragraph text here&lt;\/p&gt;\r\n&lt;button&gt;A button here&lt;\/button&gt;\r\n&lt;\/div&gt;&lt;!-- end child2 element --&gt;\r\n\r\n&lt;\/div&gt;&lt;!-- end parent element --&gt;\r\n<\/pre>\n<p>CSS:<\/p>\n<pre class=\"brush:css\">\r\n.parent h3 {\r\n\tfont-variant: small-caps;\r\n\tcolor: red;\r\n}\r\n\r\n.parent p {\r\n\ttext-indent: 1em;\r\n\tcolor: blue;\r\n}\r\n\r\n.parent button {\r\n\tpadding: 1em 2em;\r\n\tbackground-color: gray;\r\n\tcolor: white;\r\n\tborder-radius: 0.5em;\r\n\tborder: 0.1em solid gray;\r\n}\r\n\r\n.child2 p {\t\t\t\t\t\t\/* declined inherited attributes from parent *\/\r\n\ttext-indent: inherit;\t\r\n\tcolor: inherit;\r\n}\r\n\r\n.child2 h3 {\t\t\t\t\t\/* declined inherited attributes from parent *\/\r\n\tfont-variant: inherit;\r\n\tcolor: inherit;\r\n}\r\n\r\n.child2 button {\t\t\t\t\/* declined inherited attributes from parent *\/\r\n\tbackground-color: inherit;\r\n\tcolor: inherit;\r\n}\r\n<\/pre>\n<p>Lets look at the browser view and then comment it:<br \/>\n<figure id=\"attachment_4216\" aria-describedby=\"caption-attachment-4216\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit4.jpg\" alt=\"Vice-Versa Inheritance\" width=\"800\" height=\"296\" class=\"size-full wp-image-4216\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit4.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit4-300x111.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4216\" class=\"wp-caption-text\">Vice-Versa Inheritance<\/figcaption><\/figure><br \/>\nNotice that the parent attributes are applied to the first child but not to the second one.<\/p>\n<p>That is because we chose to inherit attributes when they were already automatically inherited.<\/p>\n<p><strong>This case would result in an inheritance of the default attributes of a higher level parent (i.e body).<\/strong><\/p>\n<h3> 3.3 Tag and Location Inheritance<\/h3>\n<p><\/p>\n<p>&#8211; <strong>Tag Inheritance<\/strong><\/p>\n<p>To explain this, take for example the <code>button<\/code> tag of html:<\/p>\n<pre class=\"brush:xml\">&lt;button&gt;Button&lt;\/button&gt;<\/pre>\n<p>With no styling at all, this element has already a view (attributes):<br \/>\n<figure id=\"attachment_4220\" aria-describedby=\"caption-attachment-4220\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit5.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit5.jpg\" alt=\"Tag Inheritance - Button Example\" width=\"800\" height=\"120\" class=\"size-full wp-image-4220\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit5.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit5-300x45.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4220\" class=\"wp-caption-text\">Tag Inheritance &#8211; Button Example<\/figcaption><\/figure><\/p>\n<p>You can see it has a <code>border<\/code>, a gradient <code>background<\/code>, a <code>hover<\/code> state ect.<\/p>\n<p>This is called tag inheritance, it means the element inherits default properties\/attributes pre set by the browser.<\/p>\n<p>Whenever you style a button, you just override the browser default properties for that element.<br \/>\n<\/p>\n<p>&#8211; <strong>Location Inheritance<\/strong><\/p>\n<p>Basically, location inheritance means using the same attributes for a set of elements under the same tag\/class.<\/p>\n<p>For example, if you want to have all titles styled with a green color and bold you could just refer to the following:<\/p>\n<pre class=\"brush:css\">\r\n.title {\r\n\tcolor: green;\r\n\tfont-weight: bold;\r\n\tfont-size: 2em;\r\n}\r\n<\/pre>\n<p>And apply this class to all elements wrapping a title like so:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;div class=\"title\"&gt;2. Why us? &lt;\/div&gt;\r\n\r\n&lt;p&gt;Just a paragraph to show that this is not a title.&lt;\/p&gt;\r\n&lt;ul&gt;\r\n\t&lt;li&gt;First&lt;\/li&gt;\r\n\t&lt;li&gt;Second&lt;\/li&gt;\r\n\t&lt;li&gt;Third&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n\r\n&lt;div class=\"title\"&gt;3. Help Center &lt;\/div&gt;\r\n<\/pre>\n<p>Notice that elements given the <code>title<\/code> class now have a title look and feel.<br \/>\n<figure id=\"attachment_4222\" aria-describedby=\"caption-attachment-4222\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit6.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit6.jpg\" alt=\"Location Inheritance - Title Example\" width=\"800\" height=\"234\" class=\"size-full wp-image-4222\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit6.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit6-300x88.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4222\" class=\"wp-caption-text\">Location Inheritance &#8211; Title Example<\/figcaption><\/figure><\/p>\n<h3> 3.4 Class Inheritance<\/h3>\n<p>Class inheritance is more and more being used in nowadays websites.<\/p>\n<p>It means to apply certain styles from a predefined class, and other styles from another predefined class.<\/p>\n<p>Take, for example, the multiple classes application in css, like below:<\/p>\n<p>HTML<\/p>\n<pre class=\"brush:xml\">\r\n&lt;p&gt;Just a paragraph here. It could be lorem ipsum.&lt;\/p&gt;\r\n&lt;ul class=\"text-style-1\"&gt;\r\n\t&lt;li&gt;This will be just a text line&lt;\/li&gt;\r\n\t&lt;li class=\"link bold\"&gt;Download Now&lt;\/li&gt;\r\n\t&lt;li&gt;Third line goes here&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p>CSS<\/p>\n<pre class=\"brush:css\">\r\n.text-style-1 {\r\n\tcolor: #50838e;\r\n\tfont-weight: italic;\r\n\tfont-size: 1.2em;\r\n}\r\n\r\n.link {\r\n\tcolor: blue;\r\n\ttext-decoration: underline;\r\n}\r\n\r\n.bold {\r\n\tfont-weight: bolder;\r\n}\r\n<\/pre>\n<p>So above I have declared three classes and given them attributes.<\/p>\n<p>Then, I have used them to style the elements by giving them these classes.<br \/>\n<figure id=\"attachment_4227\" aria-describedby=\"caption-attachment-4227\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit7.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit7.jpg\" alt=\"Class Inheritance - Text Example\" width=\"800\" height=\"146\" class=\"size-full wp-image-4227\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit7.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/inherit7-300x55.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-4227\" class=\"wp-caption-text\">Class Inheritance &#8211; Text Example<\/figcaption><\/figure><\/p>\n<p>Now all three lines will have the attributes of <code>text-style-1<\/code> but in addition to that, the second <code>li<\/code> is going to have added the attributes of the <code>link<\/code> class and the <code>bold<\/code> class.<\/p>\n<p>We can say that the second line <strong>inherits<\/strong> all ul attributes and just keeps adding new (or overriding existing) attributes.<\/p>\n<h2> 4. Conclusion <\/h2>\n<p>On a more professional approach, we can state that using inheritance is not of much usage as most elements will need specific styling and independence from parent elements they are in.<\/p>\n<p>However, when using inheritance property value to give elements styling attributes, keep in mind that <code>inherit<\/code> can be applied  just as a single value (i.e you can&#8217;t have something like: border: inherit 1em #ccc; ) so you don&#8217;t get individual values inherited.<\/p>\n<p>If you want to see the browser default styles (from which your element attributes are inherited), you can inspect element and check &#8220;Show Inherited Properties&#8221; in Chrome.<\/p>\n<h2>5. Download <\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/CSS-Inheritance-Example.zip\"><strong>CSS Inheritance Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we&#8217;ll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit. Before we go straight into that, know the following: Each element in HTML is part of a &#8216;tree&#8217;, and every element (except the initial html element) has &hellip;<\/p>\n","protected":false},"author":75,"featured_media":917,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-4168","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CSS Inheritance Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example, we&#039;ll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Inheritance Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example, we&#039;ll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/fabiocimo\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-11T09:15:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-08T12:38:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Fabio Cimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fabiocimo\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fabio Cimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\"},\"author\":{\"name\":\"Fabio Cimo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\"},\"headline\":\"CSS Inheritance Example\",\"datePublished\":\"2015-05-11T09:15:52+00:00\",\"dateModified\":\"2018-01-08T12:38:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\"},\"wordCount\":1181,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"articleSection\":[\"CSS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\",\"name\":\"CSS Inheritance Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"datePublished\":\"2015-05-11T09:15:52+00:00\",\"dateModified\":\"2018-01-08T12:38:51+00:00\",\"description\":\"In this example, we'll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/css\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSS Inheritance Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\",\"name\":\"Fabio Cimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"caption\":\"Fabio Cimo\"},\"description\":\"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.\",\"sameAs\":[\"https:\/\/www.facebook.com\/fabiocimo\",\"https:\/\/al.linkedin.com\/in\/fabiocimo\",\"https:\/\/x.com\/fabiocimo\",\"https:\/\/www.youtube.com\/fabiocimo1\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Inheritance Example - Web Code Geeks - 2026","description":"In this example, we'll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/","og_locale":"en_US","og_type":"article","og_title":"CSS Inheritance Example - Web Code Geeks - 2026","og_description":"In this example, we'll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit.","og_url":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/fabiocimo","article_published_time":"2015-05-11T09:15:52+00:00","article_modified_time":"2018-01-08T12:38:51+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","type":"image\/jpeg"}],"author":"Fabio Cimo","twitter_card":"summary_large_image","twitter_creator":"@fabiocimo","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Fabio Cimo","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/"},"author":{"name":"Fabio Cimo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22"},"headline":"CSS Inheritance Example","datePublished":"2015-05-11T09:15:52+00:00","dateModified":"2018-01-08T12:38:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/"},"wordCount":1181,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","articleSection":["CSS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/","url":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/","name":"CSS Inheritance Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","datePublished":"2015-05-11T09:15:52+00:00","dateModified":"2018-01-08T12:38:51+00:00","description":"In this example, we'll focus on a css property value that I guess many of you ignore (do not use) while styling elements on websites. It is inherit.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/css\/css-inheritance-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"CSS","item":"https:\/\/www.webcodegeeks.com\/category\/css\/"},{"@type":"ListItem","position":3,"name":"CSS Inheritance Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22","name":"Fabio Cimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","caption":"Fabio Cimo"},"description":"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.","sameAs":["https:\/\/www.facebook.com\/fabiocimo","https:\/\/al.linkedin.com\/in\/fabiocimo","https:\/\/x.com\/fabiocimo","https:\/\/www.youtube.com\/fabiocimo1"],"url":"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/4168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=4168"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/4168\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/917"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=4168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=4168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=4168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}