CSS Reference ยท Custom Properties, Cascade and Global Keywords
The revert keyword
Reference for the CSS revert keyword: how it rolls a property back to the user-agent or user style, how it differs from initial and unset, with live examples.
The revert keyword is one of the CSS-wide keywords: every property accepts it. It removes the declarations of the author origin (your stylesheets) for that property and lets the value from the previous origin win instead. In practice that means the browser's default style, or the user's own stylesheet if they have one.
This is different from "the property's initial value". A <ul> has display: block and a bullet style because the browser's stylesheet says so. revert brings those back; initial would not.
button.plain { all: revert; /* back to how a native button looks */ } h2 { margin: revert; }
Try it
Syntax
property: revert;
- Initial value: not applicable;
revertis a keyword you write. - Applies to: all elements and all properties, including the
allshorthand. - Inherited: follows the property you use it on.
- Animatable: no.
- Computed value: whatever the previous origin gives the property.
Values
| Value | Description |
|---|---|
revert |
Discard author-origin declarations for this property and use the user (or, failing that, user-agent) value. |
Usage notes
- Origins. The cascade has three main origins: user-agent (browser defaults), user (rare, set in browser settings or extensions) and author (your CSS).
revertin an author rule rolls back to the next lower origin that sets the property. - Browser defaults come back, not "nothing". After
display: reverton a<li>you getlist-item; on a<div>you getblock; on a<span>you getinline. all: revertis useful to remove all of your styles from a component, for example to make a native widget look native again inside a heavily styled area. Note that it also revertsdisplay, so make sure that is what you want.- Not the same as
unset.unsetacts likeinheritfor inherited properties andinitialfor the others, ignoring browser defaults entirely. - Layers.
revertjumps back across all author styles. To undo only the current cascade layer, userevert-layer. - Presentational hints. Some HTML attributes (like
widthon an image) behave like author-origin hints with very low priority; they are also rolled back byrevert.
Browser support
Supported in all current major browsers; it has been available across them for several years.
Related
revert-layerโ roll back one layer onlyinitial,inherit,unset,allcascade and specificity- Lesson: Global values