inherit

  • Revision slug: CSS/inherit
  • Revision title: inherit
  • Revision id: 292684
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The {{ cssxref("inherit") }} value is allowed on every CSS property. It causes the element for which it is specified to take the {{ Xref_csscomputed() }} of the property from its parent element.

For inherited properties

For inherited properties, this reinforces the default behavior, and is only needed to override another rule. For example:

 /* make second-level headers green */
 h2 { color: green; }

 /* ...but leave those in the sidebar alone so they use their parent's color */
 #sidebar h2 { color: inherit; }

Note that in this example the h2 elements inside the sidebar might be different colors. For example, if one of them were the child of a div matched by the rule

 div#current { color: blue; }

it would be blue.

For non-inherited properties

For non-inherited properties, this specifies a behavior that typically makes relatively little sense.

Notes

Inheritance is always from the parent element in the document tree, even when the parent element is not the containing block.

Specifications

Specification Status Comment
CSS Values and Units Level 3 {{ Spec2('CSS3 Values') }} No significant change from CSS Level 2 (Revision 1)
CSS Level 2 (Revision 1) {{ Spec2('CSS2.1') }}  

Browser compatibility

Browser Lowest Version
Internet Explorer 8.0
Firefox (Gecko) 1.0 (1.0)
Opera 4.0-7.0
Safari (WebKit) 1.0 (85)

See also

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The {{ cssxref("inherit") }} value is allowed on every CSS property. It causes the element for which it is specified to take the {{ Xref_csscomputed() }} of the property from its parent element.</p>
<h2 id="For_inherited_properties" name="For_inherited_properties">For inherited properties</h2>
<p>For <a href="/en/CSS/inheritance" title="en/CSS/inheritance">inherited properties</a>, this reinforces the default behavior, and is only needed to override another rule. For example:</p>
<pre>
 /* make second-level headers green */
 h2 { color: green; }

 /* ...but leave those in the sidebar alone so they use their parent's color */
 #sidebar h2 { color: inherit; }
</pre>
<p>Note that in this example the<code> h2 </code>elements inside the sidebar might be different colors. For example, if one of them were the child of a div matched by the rule</p>
<pre class="eval">
 div#current { color: blue; }
</pre>
<p>it would be blue.</p>
<h2 id="For_non-inherited_properties" name="For_non-inherited_properties">For non-inherited properties</h2>
<p>For <a href="/en/CSS/inheritance" title="en/CSS/inheritance">non-inherited properties</a>, this specifies a behavior that typically makes relatively little sense.</p>
<h2 id="Notes" name="Notes">Notes</h2>
<p>Inheritance is always from the parent element in the document tree, even when the parent element is not the containing block.</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th>Specification</th>
      <th>Status</th>
      <th>Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="external" href="http://www.w3.org/TR/css3-values/#common-keywords" title="http://www.w3.org/TR/css3-values/#common-keywords">CSS Values and Units Level 3</a></td>
      <td>{{ Spec2('CSS3 Values') }}</td>
      <td>No significant change from CSS Level 2 (Revision 1)</td>
    </tr>
    <tr style="vertical-align: top;">
      <td style="vertical-align: top;"><a class="external" href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit" title="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">CSS Level 2 (Revision 1)</a></td>
      <td style="vertical-align: top;">{{ Spec2('CSS2.1') }}</td>
      <td style="vertical-align: top;">&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Browser compatibility</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th>Browser</th>
      <th>Lowest Version</th>
    </tr>
    <tr>
      <td>Internet Explorer</td>
      <td><strong>8.0</strong></td>
    </tr>
    <tr>
      <td>Firefox (Gecko)</td>
      <td><strong>1.0</strong> (1.0)</td>
    </tr>
    <tr>
      <td>Opera</td>
      <td>4.0-7.0</td>
    </tr>
    <tr>
      <td>Safari (WebKit)</td>
      <td><strong>1.0</strong> (85)</td>
    </tr>
  </tbody>
</table>
<h2 id="See_Also" name="See_Also">See also</h2>
<ul>
  <li><a class="internal" href="/es/CSS/inheritance" title="es/CSS/inheritance">Inheritance</a></li>
  <li>{{ cssxref("initial") }}</li>
</ul>
Revert to this revision