HTML CSS examples for CSS:Introduction
Set color to inherit
<!DOCTYPE html> <html> <head> <style> span {<!-- www . j av a 2s. c o m--> color: blue; border:1px solid black; } </style> </head> <body> <div>Here is <span>a span element</span> inside an element with no color property set. <div style="color:green"> Here is <span id="mySpan">a span element</span> inside an element with color:green. </div> </div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("mySpan").style.color = "inherit"; } </script> </body> </html>