The Wayback Machine - https://web.archive.org/web/20230323070048/https://www.geeksforgeeks.org/css-value-unset/
Skip to content
Related Articles
Open in App
Not now

Related Articles

CSS Value | Unset

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 24 Aug, 2022
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!