Skip to content
Tutorials Center
My learning

Topics

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.

CSS
button.plain {
  all: revert; /* back to how a native button looks */
}

h2 {
  margin: revert;
}

Try it

revert vs initial vs unset

Syntax

CSS
property: revert;
  • Initial value: not applicable; revert is a keyword you write.
  • Applies to: all elements and all properties, including the all shorthand.
  • 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). revert in an author rule rolls back to the next lower origin that sets the property.
  • Browser defaults come back, not "nothing". After display: revert on a <li> you get list-item; on a <div> you get block; on a <span> you get inline.
  • all: revert is 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 reverts display, so make sure that is what you want.
  • Not the same as unset. unset acts like inherit for inherited properties and initial for the others, ignoring browser defaults entirely.
  • Layers. revert jumps back across all author styles. To undo only the current cascade layer, use revert-layer.
  • Presentational hints. Some HTML attributes (like width on an image) behave like author-origin hints with very low priority; they are also rolled back by revert.

Browser support

Supported in all current major browsers; it has been available across them for several years.