Open In App

CSS Value | Unset

Improve
Improve
Like Article
Like
Save
Share
Report

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.

html




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

html




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

  • Chrome 41
  • Safari 9.1
  • Edge 13
  • Firefox 27
  • Opera 28


Last Updated : 24 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads