Open In App

CSS Value | Unset

To unset the value of an element, unset keyword is used.

The unset CSS keyword resets a property of an element to its inherited value if the property naturally inherits from its parent, or to its initial value if it does not inherit. In other words, it behaves like the inherit keyword in the first case, if the property is being inherited and like the initial keyword in the second case, if the property is not being inherited.



Syntax:

property_name: unset;

Example 1: unsetting the font color of an element to the initial default.






<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
  <title>CSS | value unset</title>
</head>
<style>
 
span {
    color: blue;
}
.gfg {
    color: unset;
}
</style>
<body>
    <h1 style="text-align: center; color: green;">
         GeeksforGeeks
    </h1>
    <div style="text-align: center;">
     <span class="gfg">Font color unset</span>
    </div>
</body>
</html>

Output:

Example 2: Unsetting the font color to equivalent parent element’s value.




<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
  <title>CSS | value unset</title>
</head>
<style>
 
span {
    color: blue;
}
.gfg {
    color: unset;
}
</style>
<body>
    <h1 style="text-align: center; color: green;">
         GeeksforGeeks
    </h1>
    <div style="text-align: center; color: green;">
     <span class="gfg">
         Font color unset inherited from parent div
     </span>
    </div>
</body>
</html>

Output:

Supported Browsers:


Article Tags :