CSS initial, inherit, unset and revert Keywords

Introduction

CSS provides global, or CSS-wide, keyword values that tell the browser how to obtain a property's value instead of supplying an ordinary color, length, display mode, or other property-specific value. Four of the most important are initial, inherit, unset, and revert. They can restore a specification baseline, copy a parent value, return to natural defaulting behavior, or roll back declarations from the current cascade origin.

These keywords look similar because each can remove the visible effect of an earlier declaration, but they do not mean “reset” in the same way. The correct choice depends on the property's inherited status, the parent's computed value, browser and user styles, author cascade layers, and the desired component boundary. Understanding those differences prevents accidental loss of native controls, unexpected typography, and broad resets that are harder to maintain than the styles they replace.

What Are CSS-Wide Keywords?

A CSS-wide keyword is a predefined value understood across CSS properties. Instead of describing a property's normal domain, it invokes a standard defaulting or rollback behavior. All CSS properties accept the relevant CSS-wide keywords through the value-processing rules, even when the property's ordinary grammar does not mention them repeatedly.

.example {
  color: inherit;
  margin: initial;
  border: unset;
  display: revert;
}

Each declaration still participates in the cascade. The browser first selects the winning declaration, then interprets its keyword to determine the specified value through the corresponding defaulting rule.

The Main Keyword Meanings

KeywordMeaningMain question answered
initialUse the property's specification-defined initial valueWhat is the property's baseline value?
inheritUse the inherited value from the parentWhat computed value does the parent provide?
unsetUse inherit for inherited properties, otherwise initialHow would this property naturally default?
revertRoll back declarations from the current cascade originWhat would a lower origin provide?
revert-layerRoll back the current cascade layerWhat would a lower-priority layer provide?

Where the Keywords Fit in Value Processing

The cascade collects relevant declarations and selects a winning cascaded value for each property on each element. If that winner is a CSS-wide keyword, the keyword determines the property's specified value. The browser then resolves computed, used, and actual values according to the property and layout context.

This order matters because a keyword declaration can itself lose the cascade. A low-priority color: inherit has no effect if a stronger declaration sets color directly. The keyword is not an instruction outside the cascade; it is the winning value only when its declaration wins.

Understanding initial

The initial keyword selects the initial value defined by the property's specification. Every property has an initial value, whether or not the property normally inherits. Initial is independent of the parent's value and does not ask what the browser's user-agent stylesheet would normally apply to that HTML element.

.summary {
  color: initial;
  margin: initial;
  position: initial;
}

Color returns to its property baseline, margin becomes its initial zero values, and position becomes static. The exact result should be checked in the relevant property definition rather than guessed from an element's familiar appearance.

Initial Is Not the Browser Default Style

A property's initial value comes from the CSS specification. A browser's default presentation usually comes from user-agent stylesheet rules. These are different sources. The initial value of display is an inline outside display type for ordinary elements, while a browser normally gives a div block behavior through its user-agent stylesheet.

Therefore, display: initial on a div does not mean “restore the usual div display.” It selects the property's initial value. Use revert when the goal is to expose lower-origin browser behavior.

Initial on an Inherited Property

Using initial on an inherited property deliberately stops natural inheritance. If body establishes navy text and a paragraph declares color: initial, the paragraph uses the initial color rather than the parent's navy computed color.

body {
  color: navy;
}

.disconnected {
  color: initial;
}

This can be useful at a deliberate visual boundary, but it may ignore theme and user context. A semantic custom property or component token is often safer than disconnecting a descendant from inherited foreground color.

Initial on a Non-Inherited Property

For a non-inherited property, initial often matches what would happen if no declarations applied at all, because non-inherited properties naturally fall back to their initial values. For example, margin: initial produces the initial zero margins.

The declaration is still explicit and can win over earlier rules. It is useful when a component must cancel an author value, but it should not be added merely to restate normal defaults on every element.

When to Use initial

Use initial when the specification baseline is the actual desired result, especially when stopping inheritance or cancelling a previous author declaration for one property. It is appropriate when the team's intent is independent of both the parent and native element presentation.

Do not choose initial merely because the word sounds like “original browser style.” Confirm the property's initial value first, and test semantic controls and layout elements whose user-agent defaults differ from that baseline.

Understanding inherit

The inherit keyword explicitly selects the inherited value, which is normally the parent's computed value for that property. It works on every property, including properties that do not inherit by default. On the root element, where no parent exists, the inherited value resolves to the property's initial value.

.toolbar {
  color: navy;
}

.toolbar a {
  color: inherit;
}

The link follows the toolbar's computed color instead of using a direct browser or author link color. It still needs a visible focus and interaction treatment.

Inherit Uses the Parent's Computed Value

The child receives the computed value from the parent, not necessarily the exact token written in the parent's declaration. Relative units, variables, and property-specific normalization may already have been resolved. This produces stable propagation through nested trees.

For example, an inherited font size can be a computed length even if the parent declaration used a percentage. A unitless line height retains behavior designed to scale with descendant fonts according to its computed-value rules.

Forcing a Non-Inherited Property to Inherit

Inherit can copy box and layout properties that normally remain local. A child can declare border: inherit, padding: inherit, or background: inherit. The browser then uses the parent's computed longhand values.

.panel {
  border: 2px solid navy;
}

.panel__message {
  border: inherit;
}

This creates a strong parent-child dependency. Use it only when copying the parent's result is genuinely the component contract; otherwise expose a custom property or shared class.

Inherit and Shorthand Properties

Applying inherit to a shorthand causes each longhand represented by that shorthand to inherit. border: inherit copies border widths, styles, and colors. font: inherit synchronizes the font shorthand's longhand values and is commonly used for controls.

Shorthand inheritance can transfer more than the visible requirement. Prefer individual longhands when only one aspect should follow the parent, and inspect expanded values in DevTools.

Common Form-Control Pattern

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

Native controls often receive direct user-agent font and color declarations. Explicit inheritance can align them with surrounding typography while keeping native behavior for other properties. This pattern should be tested across operating systems, autofill, disabled states, mobile inputs, forced colors, and high contrast.

Do not combine it casually with all: unset, which removes many useful native and accessibility affordances.

When to Use inherit

Use inherit when a child should intentionally mirror the parent's computed result, especially after another rule or user-agent style supplied a direct value. Links, controls, decorative pseudo-elements, and nested component text are common cases.

Avoid writing inherit redundantly on properties already inheriting naturally unless the declaration communicates an override. For reusable theme APIs, inherited custom properties often provide a clearer named contract.

Understanding unset

The unset keyword follows the property's natural inherited status. If the property is inherited by default, unset behaves like inherit. If it is not inherited, unset behaves like initial. It effectively removes earlier declarations while preserving the defaulting model defined for that property.

Unset is useful when code should not need a hard-coded branch for every property. It does not mean “remove the property from CSS,” and it does not necessarily restore user-agent presentation.

Unset on an Inherited Property

body {
  color: navy;
}

.article-note {
  color: crimson;
}

.article-note.is-neutral {
  color: unset;
}

Because color inherits by default, the neutral note uses the parent's computed color. Unset cancels the earlier direct author value and returns the property to normal inherited behavior.

If the parent color later changes through a theme, the neutral note follows automatically. This can be more maintainable than repeating a specific fallback color.

Unset on a Non-Inherited Property

.card {
  border: 2px solid navy;
}

.card.is-plain {
  border: unset;
}

Border does not inherit, so unset behaves like initial. The border longhands return to their initial state, which results in no visible border. It does not copy a surrounding container's border.

The same pattern can reset margin, padding, positioning, or other non-inherited properties to their specification baselines.

Unset Is Property-Aware

Unset's behavior depends on each property's inherited flag, not on the element, selector, or current parent value. Two declarations in the same rule can therefore follow different paths: color: unset inherits, while margin: unset uses initial values.

This property-aware behavior is useful for generic resets but can confuse readers who expect one fixed meaning. Use comments or more explicit keywords when the distinction is important to component design.

When to Use unset

Use unset when the desired outcome is the property's natural defaulting behavior rather than a specific initial, inherited, or browser-provided result. It is effective for neutral variants, component cleanup, and generated styles that handle many property types.

Do not choose unset when native element presentation is required. Because user-agent declarations are still separate cascade values, revert may express that intention more accurately.

Understanding revert

The revert keyword rolls the property back across the current cascade origin. In ordinary author CSS, it calculates the result as though author-origin declarations for that property on the element did not exist, exposing user or user-agent styling. It therefore respects lower-origin cascade behavior rather than selecting one universal value.

The result can vary by element, browser, platform, user settings, and property. That variability is often exactly what is wanted when restoring native semantics.

Revert in the Author Origin

button {
  display: flex;
  appearance: none;
}

.native-button {
  display: revert;
  appearance: revert;
}

For the native-button variant, author declarations for those properties are rolled back so user or browser values can surface. The precise result depends on lower-origin rules and the platform.

Revert affects the selected property on the selected element. It does not remove unrelated author declarations unless used through the all shorthand.

Revert in Other Origins

The meaning of revert depends on the declaration's origin. In author origin it rolls back author styling and exposes user or user-agent results. In user origin it rolls back user and author influence for that property to the user-agent level. In user-agent origin, revert behaves like unset because no earlier origin remains.

Most developers write author CSS, but the origin-dependent definition explains why revert cannot be reduced to “browser default” in every context.

Revert Versus initial

Initial selects a property-defined value. Revert asks the cascade what would win without declarations from the current origin. For a div's display, initial can produce inline behavior, while revert commonly exposes the browser's block rule. For a button, revert can restore platform presentation that no single initial value describes.

Choose initial for a specification baseline and revert for lower-origin behavior. This distinction is one of the most important lessons in reset design.

Revert Versus unset

Unset follows inheritance status: inherit if naturally inherited, otherwise initial. Revert follows cascade origins. On an inherited property, author-origin revert may expose a user or browser declaration on the element; if none applies, normal defaulting may eventually inherit. On a non-inherited property, revert can expose a user-agent value different from initial.

Use unset to restore natural property behavior and revert to undo the current origin's influence.

When to Use revert

Use revert when broad author CSS has overridden meaningful native or user presentation and a component should opt out. Semantic buttons, links, lists, headings, and controls are common candidates when restoring lower-origin behavior is preferable to manually recreating defaults.

Test across supported browsers and operating systems because user-agent styles are intentionally platform-sensitive. Revert restores the cascade, not a pixel-identical cross-browser design.

Understanding revert-layer

revert-layer is another CSS-wide keyword that rolls back declarations from the current cascade layer instead of the entire origin. It reveals values from lower-priority layers in that origin. If no lower layer supplies a value, rollback can continue toward an earlier origin according to cascade rules.

This is useful in layered architectures where a utility, theme, or component variant should undo only its current layer's contribution while preserving foundational author styles.

Revert-Layer Example

@layer base, components, utilities;

@layer base {
  button { color: navy; }
}

@layer components {
  .action { color: white; }
}

@layer utilities {
  .use-component-color { color: revert-layer; }
}

The utility-layer rollback exposes the components-layer color for an action button rather than jumping directly to browser styling. Layer order and important-layer reversal still determine the applicable rollback path.

Revert and Important Declarations

A revert declaration participates in the cascade like any other declaration. If it is normal, an important declaration can defeat it. If revert is marked important, it rolls back according to the applicable important cascade context after winning its category.

Do not add important automatically when revert appears ineffective. Identify the current origin, importance, layer, inline value, animation, transition, specificity, and source order first.

The all Shorthand

The all property applies one CSS-wide keyword to nearly every standard property at once. It accepts initial, inherit, unset, revert, or revert-layer. It is a powerful boundary tool and a high-risk reset because it changes layout, typography, painting, interaction cues, and effects simultaneously.

.embedded-widget {
  all: revert;
}

Use all only when the component boundary is clear and the required presentation is rebuilt and tested.

What all Does Not Reset

The all shorthand excludes direction and unicode-bidi. Those properties relate closely to document-language direction and should normally be controlled through semantic markup such as the HTML dir attribute. All also does not reset custom properties.

A widget using all: unset can therefore continue receiving inherited design tokens through double-dash custom properties. That may be useful or surprising, depending on the intended isolation.

all: initial

all: initial assigns each affected property's specification initial value. Inherited typography is stopped, display can change, native element rules are not restored, and many familiar defaults disappear. It creates a low-level CSS baseline rather than an unstyled HTML baseline.

This is rarely appropriate for semantic controls or document content. If used for a custom rendering surface, explicitly reconstruct focus, sizing, accessibility states, and responsive behavior.

all: inherit

all: inherit forces almost every affected property to use the parent's inherited value, including properties that normally do not inherit. The child can receive the parent's margins, padding, border, display-related values, and effects where those properties accept inheritance.

This broad coupling is seldom desirable. Use individual inherited properties or custom tokens unless the element is intentionally designed as a complete visual clone of its parent context.

all: unset

all: unset makes each affected inherited property inherit and each affected non-inherited property use its initial value. It preserves natural text inheritance while stripping many local box and control styles. That combination can be useful for small custom elements but dangerous for interactive HTML.

A button reset this way may lose its native display, border, background, focus treatment, and cursor cues. Semantics remain in HTML, but visible affordances must be rebuilt.

all: revert

all: revert rolls all affected properties back across the current origin. In author CSS, it can expose user and browser styles across the element, making it the closest of these options to restoring native presentation.

It still does not mean one universal appearance. Browser, platform, and user differences become visible. Add new author declarations after the reset for the component-specific changes you actually need.

all: revert-layer

all: revert-layer removes the current layer's contribution across affected properties while preserving lower-priority layers. It can create an opt-out utility for a theme or component layer without discarding the entire author styling system.

Broad layer rollback should be documented because future declarations added to lower layers can change the resulting component. Focused property-level rollback is often easier to reason about.

Custom Properties and Global Keywords

Custom properties inherit by default unless registered otherwise, but the all shorthand does not reset them. Components that depend on inherited custom tokens can retain those tokens even after all: unset or all: revert.

Reset or redefine custom properties explicitly when true token isolation is needed. A registered custom property can use inherits: false and an initial value to establish local behavior, but that contract should be documented.

Global Keywords in Shorthands

A shorthand set to a CSS-wide keyword applies that behavior to every longhand represented by the shorthand. margin: initial resets all four margins. font: inherit inherits the font longhands. border: revert rolls back border width, style, and color components.

Do not combine a CSS-wide keyword with ordinary values inside one shorthand. Use longhands when different components require different reset behaviors.

Restoring Native Buttons

A project may apply broad button styles and then need a native-looking control in a specialized context. all: revert can expose browser and user presentation, after which focused author rules can add spacing or layout without rebuilding every native property.

Test keyboard focus, disabled state, forced colors, touch size, font behavior, and platform appearance. Native restoration is functional behavior, not merely a visual shortcut.

Making Links Match Parent Text

Links often receive direct user-agent or author colors. A component can use color: inherit when a link should follow its parent's computed foreground. This is more accurate than guessing the theme's current color.

Preserve link recognition through underline, weight, iconography, or other cues, and provide visible hover and focus states. Inheriting color should not make an interactive link indistinguishable from ordinary text.

Neutralizing a Component Variant

Unset works well when a variant should return properties to natural behavior. A neutral text variant can use color: unset to inherit, while border: unset returns a non-inherited border to its initial state.

This pattern avoids hard-coded fallback values and follows theme changes. Ensure maintainers understand that the same keyword takes two paths based on each property.

Undoing Framework Styles

Before using global keywords against a framework, identify whether the framework rule belongs to a layer, uses important, writes inline values, or sets custom properties. revert-layer is useful when framework styles occupy a known lower or current layer. Revert can expose browser styles, while unset selects natural property defaulting.

Prefer the framework's theme and component APIs. Broad resets against internal markup can break on upgrades and may remove accessibility states.

Component Isolation Strategy

Global keywords can define a boundary, but isolation is rarely achieved by one reset. Components also depend on inherited language, direction, fonts, custom tokens, focus conventions, sizing context, and portal placement. Decide which context should flow in and which values the component owns.

Use stable classes, layers, custom properties, and targeted resets. Test nested components so an outer reset does not erase an inner component's contract.

Global Keywords and Cascade Layers

Initial, inherit, and unset select values through defaulting after their declarations win. Revert-layer explicitly changes layer rollback. Revert rolls back the current origin. The declaration containing any keyword can itself be placed in a named layer and must first win normal cascade precedence.

Define layer order centrally. A rollback keyword without an understood layer and origin architecture can produce correct but surprising results.

Global Keywords and !important

A CSS-wide keyword can be marked important, such as color: revert !important. Importance determines whether that keyword declaration wins; the keyword then performs its specified behavior in the relevant important cascade context.

Important rollback is advanced and should be narrowly documented. It is usually better to correct the original important rule or layer than to create a stronger reset category.

Debugging in DevTools

Inspect the element and property. DevTools shows the winning declaration, crossed-out competitors, inherited values, user-agent styles, inline values, and often cascade layers. The Computed panel reveals the final computed value after a keyword has been resolved.

For initial, check the property's defined initial value. For inherit, inspect the parent's computed value. For unset, confirm inherited status. For revert, locate lower-origin rules. For revert-layer, inspect the declared layer order.

A Keyword Decision Process

Ask what result is actually desired. If the specification baseline is required, use initial. If the parent result should be copied, use inherit. If the property should return to its natural inherited-or-initial behavior, use unset. If author styling should be removed to expose user or browser rules, use revert. If only the current layer should be removed, use revert-layer.

Then decide whether the change belongs on one property, a shorthand, or the broad all shorthand. Prefer the narrowest declaration that expresses the requirement.

Common Mistake: initial Means Native Default

Initial does not restore semantic element defaults from the user-agent stylesheet. A div, heading, list, or button can lose its familiar display and appearance when reset to specification initial values.

Use revert when lower-origin native styling is the goal. Use initial only after confirming the property baseline is appropriate.

Common Mistake: inherit Works Only on Inherited Properties

Every property accepts inherit. It can copy margins, borders, backgrounds, display values, and other normally non-inherited properties from the parent. The keyword explicitly overrides the property's natural inherited flag.

That capability is powerful but creates coupling. Use it intentionally rather than as a generic reset.

Common Mistake: unset Always Means inherit

Unset behaves like inherit only for properties defined as inherited. For non-inherited properties it behaves like initial. A rule containing multiple unset declarations can therefore produce both parent-derived and specification-initial values.

Check property definitions or DevTools when the result is not obvious. Use an explicit keyword if readers should not need to infer inherited status.

Common Mistake: revert Always Means Browser Default

Revert rolls back the current origin. In author CSS that often reveals a browser rule, but a user-origin value may win instead. If no lower-origin declaration applies, defaulting can lead to inheritance or initial values.

Describe revert as origin rollback rather than a hard-coded browser reset. That model remains accurate across user styles and different properties.

Common Mistake: all Resets Everything

The all shorthand excludes direction and unicode-bidi and does not reset custom properties. It also cannot erase semantic HTML, event behavior, ARIA state, DOM relationships, or application data. Presentation and behavior remain separate.

Use all as a CSS boundary tool, not as a complete component isolation system. Verify what remains inherited or active after the reset.

Common Mistake: Broad Resets on Controls

Applying all: unset or all: initial to buttons, inputs, selects, and textareas can remove native appearance, sizing, borders, focus cues, and platform conventions. The control may still be semantically interactive but visually unclear.

Prefer targeted normalization. If a custom control design is required, rebuild every state and test keyboard, touch, zoom, autofill, forced colors, and disabled behavior.

Advantages and Tradeoffs

KeywordMain advantageMain tradeoff
initialPredictable specification baselineMay differ from native element presentation
inheritSynchronizes with parent contextCan create hidden parent-child coupling
unsetReturns to natural property defaultingMeaning changes by inherited status
revertPreserves lower-origin user and browser behaviorResult can vary by environment
revert-layerTargets one architectural layerRequires a clear layer strategy

Interview Questions and Answers

What does initial do? It selects the property's specification-defined initial value. What does inherit do? It uses the inherited value, normally the parent's computed value. What does unset do? It behaves as inherit for inherited properties and initial for non-inherited properties.

What does revert do? It rolls back declarations from the current cascade origin. How is revert-layer different? It rolls back the current cascade layer. Does all reset custom properties? No. Is initial the same as browser default? No; browser defaults commonly come from user-agent styles.

Practical Global-Keyword Checklist

  • Choose initial only when the property specification baseline is desired.
  • Use inherit when the parent's computed result is the intended value.
  • Use unset to restore the property's natural defaulting behavior.
  • Use revert to remove the current origin's contribution.
  • Use revert-layer to remove only the current layer's contribution.
  • Prefer property-level resets over broad all declarations.
  • Remember that all excludes direction, unicode-bidi, and custom properties.
  • Test native controls, links, focus, forced colors, and user preferences.
  • Inspect layers, origins, inherited status, and computed values in DevTools.
  • Document component reset boundaries and supported customization APIs.

Key Takeaway

The global keywords solve different value-selection problems. Initial chooses the property's specification baseline. Inherit copies the parent's computed value. Unset follows the property's natural inherited-or-initial defaulting rule. Revert removes the current origin's influence, while revert-layer removes the current layer's influence. None of them is a universal synonym for “browser default.”

Choose the keyword by defining the desired source of truth: specification, parent, natural defaulting, previous origin, or previous layer. Apply it to the narrowest property set that meets the requirement, and test semantic controls and user preferences carefully. Used with a clear cascade and component architecture, these keywords make resets precise instead of destructive.