CSS unset value examples

If CSS property value is unset, then if it is an inherited property, this is treated as inherit, and if it is not, this is treated as initial. It is like erasing all declarations. Also note that it is not supported in IE.

Here is sample code using css unset

<style type="text/css">
.box {color:green;}
h2 {color: blue;}
.box > h2 {color:unset;}

<h2>h2 text</h2>
<div class="box">
  <h2>h2 text with color unset (it will use inherit as color is inherited property)</h2>

Specification and Browser compatibility

CSS unset valueW3C Candidate RecommendationCSS
Yes 41+ Yes 27+ NoYes 13+ Yes 9.1+ Yes 28+
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 9.3+ NoNo
source: caniuse.com

Related links

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments