CSS - revert
説明
プロパティの値として revert を指定することで、プロパティ値をブラウザの初期値に戻すことができます。all を含めたすべてのプロパティで
| 形式 | 属性名: revert | 
|---|---|
| サポート | https://caniuse.com/?search=revert | 
類似の値に initial, inherit, unset がありますが、違いについて説明します。下記の状態であると仮定します。
- 仕様で決められた通常要素の font-size:medium (16px)
 - ブラウザが h1 要素に対して適用している font-size:200% (32px)
 - 親要素に設定している font-size: 14px
 
この時、それぞれ下記の様に設定されます。
| initial | 仕様で決められた通常要素の値。16px | 
|---|---|
| revert | ブラウザが h1 要素に対して適用している値。32px | 
| inherit | 親要素に設定している値。14px | 
| unset | font-size のように継承するプロパティの場合は inherit と同じ。 border-color のように継承しないプロパティの場合は initial と同じ。  | 
使用例
CSS
.parent {
  font-size: 14px;
}
.initial {
  font-size: initial;
}
.revert {
  font-size: revert;
}
.inherit {
  font-size: inherit;
}
.unset {
  font-size: unset;
}
HTML
<div class="parent"> <h1 class="initial">Initial (16px)</h1> <h1 class="revert">Revert (32px)</h1> <h1 class="inherit">Inherit (14px)</h1> <h1 class="unset">Unset (14px)</h1> </div>
表示
Initial (16px)
Revert (32px)
Inherit (14px)
Unset (14px)
関連項目
initial, inherit, unsetリンク
- https://developer.mozilla.org/ja/docs/Web/CSS/revert
 - https://w3c.github.io/csswg-drafts/css-cascade-4/#default
 
Copyright (C) 2022 杜甫々
  初版:2022年9月18日、最終更新:2022年9月18日
  https://www.tohoho-web.com/css/value/revert.htm