Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

all: reset a group of properties through the cascade

Choose what a reset means instead of assuming it restores the browser’s original appearance.

Version: CSS Modules

Syntax

all: unset;

all is a shorthand accepting CSS-wide reset keywords. It resets properties except direction and unicode-bidi, and it does not reset custom properties such as --tone. It does not delete attributes, event handlers or DOM content. Like other declarations it participates in the cascade: importance, origin, layer and order still determine which values win.

initial uses each property’s specification-defined initial value; inherit takes the parent’s computed value; unset chooses inheritance for inherited properties and initial otherwise. revert rolls back the current cascade origin, while revert-layer rolls back the current layer. These are different operations. For example, the initial display value is inline, whereas the browser’s stylesheet normally gives a div display: block. The draft also lists revert-rule; its presence in the draft is not a support claim here.

The example resets a styled div with all: unset. It becomes inline, loses its 12px margin and inherits rgb(10,20,30). direction: rtl, unicode-bidi: isolate and --tone: teal survive. initial still produces inline, but revert exposes the browser’s block display. A later display: flex declaration wins over the reset. The measurements show why an indiscriminate reset can remove useful control or layout styling.

Examples

const parent = document.createElement('div');
parent.style.cssText = 'color:rgb(10,20,30);direction:rtl';
const child = document.createElement('div');
child.style.cssText = 'display:grid;margin:12px;color:red;unicode-bidi:isolate;--tone:teal;all:unset';
parent.append(child); document.body.append(parent);
let s = getComputedStyle(child);
console.log('unset:', s.display, s.marginTop, s.color);
console.log('exceptions:', s.direction, s.unicodeBidi, s.getPropertyValue('--tone').trim());
child.style.all = 'initial'; s = getComputedStyle(child);
console.log('initial:', s.display, s.marginTop);
child.style.all = 'revert'; s = getComputedStyle(child);
console.log('revert:', s.display, s.marginTop);
child.style.display = 'flex';
console.log('later declaration:', getComputedStyle(child).display);
parent.remove();

Result

unset: inline 0px rgb(10, 20, 30)
exceptions: rtl isolate teal
initial: inline 0px
revert: block 0px
later declaration: flex

Executed in Chromium 157.0.8103.51 for unset, initial, revert and the three exceptions. inherit, revert-layer and draft revert-rule are explained but not executed. Restore visible focus, usable controls and other required presentation when applying a broad reset.

Sources