+ 3
inherit
can you please explain Inherit value to me? how to use it?
5 Answers
+ 2
#parentDiv{color:red;}
p{color:blue;}
#childP{color:inherit;}
The element with inherit property value inherits that same property of it's direct parent.
In my example, the p element text will have red color. not blue.
+ 1
<p>one</p>
<p class=a>two</p>
<p id=b class=a>three</p>
p {color:green;}
.a {font-weight:bold;}
#b {font-size:24px;color:red;}
one will display in green as only the first CSS style applies to it.
two will display in green with bold text as the first two styles apply to it.
three will display in red with 24px size and bold text. All three styles apply to it, but the red color replaces the green.
+ 1
Thank you for the example.
It doesn't answer how to use inherit.. The word inherit itself should be used in the example.
I would much appreciate if you can up vote my question š
0
Fine. three inherits the color green and bold font.
0
i found this:
body {
background-image: url("http://www.sololearn.com/uploads/css_logo.png");
background-repeat: repeat-x;
}
p {
background-image: url("http://www.sololearn.com/uploads/css_logo.png");
background-repeat: inherit;
margin-top: 200px;
padding: 50px;
}