Set color to inherit - HTML CSS CSS

HTML CSS examples for CSS:Introduction

Description

Set color to inherit

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials