HTML and CSS Reference
In-Depth Information
Who gets the inheritance?
Sniff, sniff; the <body> element has gone to that
great browser in the sky. But he left behind a lot of
descendants and a big inheritance of color “green”.
Below, you'll find his family tree. Mark all the
descendants that inherit the <body> element's color
green. Don't forget to look at the CSS below first.
Here's our solution:
h 1 a n d h 2 g e t t h e i n h e ri t a n c e
b e c a u s e t h e y d o n ' t h a ve a c o l o r
p r o pe r t y , s o t h e y i n h e rit t h e i r
body
c o l o r fr o m b o d y . L u c ky t h e m !
p
p
h1
h2
h2
blockquote
a
em
a
img
p
p
em
em
a
Unfo rtunat ely for these e m
elem ents, th ey are children
of p arents that ov erride t he
body color, the p e lement.
So t hey don 't get any colo r
inhe ritance from b ody.
img is a child of p, s o img
doesn't inheri t the c olor fr om
body. i mg wou ldn't g et a co lor
inherit ance an yway (poor g uy).
 
Search WWH ::




Custom Search