Inherit - CSS Value
Summary of characteristics of the inherit value
The value inherit.
When a property is set to the inherit value, it takes on the same value as the equivalent property of the parent element.
The parent element is the one that, in the DOM tree, is above the element in question.
The inherit value is mostly used to re-enable the inheritance mechanism when a property has previously been set to a different value.
It can also enable inheritance on a property that is not inherited by default.
See also unset, initial, revert, revert-layer and revert-rule.
The inherit value and relative values.
Relative values are values that are computed from another value. Example: the em unit, which defines a dimension relative to the parent font size.
Typically, the inherit value retrieves the computed value of the parent element. The calculation is therefore not redone on the element itself.
For example, consider a font size set to 2em on the parent element. Which gives let's say 24 pixels.
Child elements will inherit the computed value (24 pixels) and not the 2em, which would ultimately give a 48 pixel font on kids.
However, there's one exception to this rule: percentages. Inheritance is done with the percentage value, not the computed value.
The left margin of this parent block is set to
25%
inherit. We can clearly see that the calculation has been redone
since the left margin does not have the same value as that of the parent element.
Examples and practical cases.
Example 1.
Force the inheritance mechanism on a property that by default does not inherit its value. This is the case of background-color.
#example1Parent Block.
#exemple1aThe background color of this block has not been changed. Its initial value is
transparent.
#example1bThe background color of this block is set to
inherit.
The color is therefore the same as that of the parent block.
Browser support (compatibility).
The inherit value is very well recognized by all current browsers.
inheritvalue
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Safari

Safari sur IOS

Opéra

Chrome

Edge

Firefox

Chrome pour Androïd

Samsung Internet

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini
The history of the inherit property.
The inherit value is also cited in the CSS Values and Units level 3 and 4 modules.
-
Cascading Style Sheets Level 2 - Revision 1 Specification
This level 2 of the specification describes the mechanism of cascading styles in CSS. This language is used to format HTML or XML documents. It supports media-specific style sheets so that authors can adapt the presentation of their documents for visual browsers, auditory devices, printers, braille devices, portable devices, etc.
RegardinginheritIntroduction of theinheritvalue to force inheritance of the parent's value.November 04, 1997Working Draft.March 24, 1998Proposed for recommendation.May 11, 1998Recommendation . -
CSS Cascading and Inheritance Level 3
This specification module introduces the values
initialandunset, as well as the shorthand propertyall.RegardinginheritNo change to theinheritvalue.July 13, 2001Working Draft.October 03, 2013Candidate Recommendation.December 22, 2020Proposed for recommendation.February 11, 2021Recommendation . -
CSS Cascading and Inheritance Level 4
This specification module introduces the
revertvalue.RegardinginheritNo change to theinheritvalue.April 21, 2015Working Draft.January 14, 2016Candidate Recommendation. -
CSS Cascading and Inheritance Level 5
This specification module introduces the concept of style layer, the
@layerdirective, and therevert-layervalue.RegardinginheritNo change to theinheritvalue.January 19, 2021Working Draft.January 13, 2022Candidate Recommendation.
See also, about values.
The CSS specifications published by the W3C are organized into modules.
The inherit property is part of the CSS Cascading and Inheritance module.
The following definitions are also described in this same module.
Properties:
At-rules:






