HTML CSS examples for CSS:Introduction
The inherit keyword sets that a property should inherit its value from its parent element.
JavaScript syntax: | object.style.property="inherit" |
---|
The following code shows how to Set the text-color for <span> elements to blue, except those inside elements with class="extra":
<!DOCTYPE html> <html> <head> <style> span {<!-- ww w . j av a 2 s . com--> color: blue; border: 1px solid black; } .extra span { color: inherit; } </style> </head> <body> <div> Here is <span>a span element</span> which is blue, as span elements are set to be. </div> <div class="extra" style="color:green"> Here is <span>a span element</span> which is green, because it inherits from its parent. </div> </body> </html>