CSS all Property

The all shorthand property resets nearly all CSS properties of an element using a single declaration.

It can restore initial values, inherit values from a parent, or roll back styles through the CSS cascade. The property affects all CSS properties except direction, unicode-bidi, and custom properties.

all Syntax

selector {
  all: initial;
}

The all property accepts CSS-wide keywords rather than ordinary property-specific values. Common values include initial, inherit, unset, revert, and revert-layer.

For example, all: unset resets inherited properties to inherited values and non-inherited properties to their initial values.

Property Values

Value Description
initial Resets affected properties to their initial values defined by CSS.
inherit Sets affected properties to their computed values from the parent element, including properties that do not normally inherit.
unset Uses inherited values for normally inherited properties and initial values for other properties.
revert Rolls affected properties back through the cascade, typically removing author-level styling so user or browser styles can apply.
revert-layer Rolls affected properties back to values determined without declarations from the current cascade layer.

The all shorthand does not have a single practical initial value. Each affected property retains its own initial value and inheritance behavior.

The newer revert-rule keyword is also defined in CSS Cascading and Inheritance Level 5, but browser support should be checked before using it in production.

How all Works

The all property works as a shorthand for nearly every CSS property. Instead of resetting properties individually, it applies one CSS-wide keyword to all affected properties at once.

.reset-box {
  all: unset;
}

This declaration resets properties such as display, margin, padding, border, color, and font-size according to the behavior of unset.

Because the property affects layout and appearance together, a reset may change an element's display type, dimensions, spacing, and text styling.

Properties declared after all in the same rule can establish new values, provided they are not overridden by declarations with higher cascade priority.

Properties Not Affected

The all shorthand has three important exceptions.

Property Behavior
direction Retains its value because it is excluded from the all shorthand.
unicode-bidi Retains its value so the shorthand does not reset bidirectional text handling.
Custom properties Properties beginning with -- are not reset by all.

For example, a custom property remains available after applying all: initial.

.custom-box {
  --accent: #1769aa;
  all: initial;
  color: var(--accent);
}

The custom property --accent is preserved, allowing the color declaration to continue using it.

The exclusions for direction and unicode-bidi help preserve text direction and bidirectional behavior.

Resetting Styles

The choice between initial, unset, and revert depends on the intended result.

Using initial

The initial keyword resets each affected property to its CSS-defined initial value, even when that differs from the browser's default styling for an HTML element.

.plain-button {
  all: initial;
}

This can remove the familiar appearance of a button, including its display behavior, font settings, border, and background. Any required styling should be added back explicitly.

Using unset

The unset keyword preserves normal inheritance behavior while resetting properties that do not inherit.

.reset-text {
  all: unset;
}

Properties such as color and font-family inherit from the parent, while non-inherited properties such as margin return to their initial values.

Using revert

The revert keyword rolls back the cascade to styles from earlier origins, which can restore browser or user-defined styling.

.default-button {
  all: revert;
}

When applied from an author stylesheet, this can restore the browser's native button appearance rather than forcing every property to its CSS initial value.

Resetting Cascade Layers

The revert-layer keyword is useful when styles are organized using the @layer at-rule. It allows a rule to roll back declarations from its current cascade layer.

@layer base, components;

@layer base {
  .notice {
    color: #1769aa;
    padding: 12px;
    border: 1px solid #1769aa;
  }
}

@layer components {
  .notice {
    color: #c0392b;
    padding: 24px;
    all: revert-layer;
  }
}

The all: revert-layer declaration rolls the affected properties back past the current layer. In this example, the values from the base layer can apply again.

Unlike revert, which rolls back through stylesheet origins, revert-layer is designed to work with cascade layers.

all Example

The following example compares a styled paragraph with two paragraphs that use all: initial and all: unset.

<div class="all-demo">
  <p class="styled">Original styling</p>
  <p class="reset-initial">all: initial</p>
  <p class="reset-unset">all: unset</p>
</div>
.all-demo {
  color: #1769aa;
  font-family: Arial, sans-serif;
  font-size: 18px;
}
.all-demo p {
  display: block;
  margin: 12px 0;
  padding: 10px;
  border: 2px solid #1769aa;
  background-color: #eaf3fa;
  color: #c0392b;
  font-size: 22px;
}
.all-demo .reset-initial {
  all: initial;
}
.all-demo .reset-unset {
  all: unset;
}

The first paragraph keeps its custom styling. The second uses CSS initial values, while the third inherits applicable text properties from the parent and resets non-inherited properties.

Browser Result

Original styling

all: initial

all: unset

Notice that the reset paragraphs lose their custom border, padding, and background. The initial value also resets inherited text styling, while unset allows properties such as color and font-family to inherit from the parent.

Important Considerations

The all property is powerful because it resets many properties simultaneously, but it should be used carefully.

  • Layout changes: Resetting display, positioning, sizing, and spacing can significantly change an element's layout.
  • Native controls: Resetting buttons and other form controls may remove their familiar visual appearance. Test keyboard focus and usability after restyling.
  • Inheritance: The values initial, inherit, and unset produce different results for inherited and non-inherited properties.
  • Custom properties: CSS variables are not reset, so they remain available for subsequent declarations.
  • Cascade priority: The shorthand still follows normal cascade rules, including specificity, importance, origins, and layers.

Use all when a broad reset is intentional. For small styling adjustments, resetting individual properties is often easier to understand and maintain.

Browser Support

The all property is widely available in modern browsers, including Chrome, Edge, Firefox, and Safari. Support for individual CSS-wide keywords, particularly newer cascade features, can vary.

Visit Can I Use? to check current browser compatibility.

Specifications

The all property is defined in the CSS Cascading and Inheritance specifications, including CSS Cascading and Inheritance Level 4 and Level 5.

CSS Cascading and Inheritance Level 4