+ 2

Can u plz explain inherit and give me some examples?

I have read it in the course and it is not that clear to me,so need some expert helpđŸ‘»

9th Sep 2017, 2:59 AM
sheikhrafe
2 Answers
+ 2
It just sets something equal to its parents attribute. So if we had something like: <html> <head> <style> p span { color: inherit; background-color:inherit; } </style> </head> <body> <p> writing <span>stuff</span> here</p> </body> </html> the span would have a different background and text color but if we add some css to that specific span to inherit the p color and background color it would be the same like this: <html> <head> <style> span { color: blue; background-color:red; } p span { color: inherit; background-color:inherit; } </style> </head> <body> <p>affected <span>stuff</span> here</p> <h2> not affected <span>stuff</span> here</h2> </body> </html> only the span in p is affected as it inherits the values.
9th Sep 2017, 3:09 AM
Enzo
Enzo - avatar