files/en-us/web/css/reference/properties/all/index.md
The all shorthand CSS property resets all of an element's properties except {{cssxref("unicode-bidi")}}, {{cssxref("direction")}}, and CSS Custom Properties. It can set properties to their initial or inherited values, or to the values specified in another cascade layer or stylesheet origin.
{{InteractiveExample("CSS Demo: all")}}
/* no all property */
all: initial;
all: inherit;
all: unset;
all: revert;
<section id="default-example">
<div class="example-container-bg">
<div class="example-container">
<p id="example-element">
This paragraph has a font size of 1.5rem and a color of gold. It also
has 1rem of vertical margin set by the user-agent. The parent of the
paragraph is a <div> with a dashed blue border.
</p>
</div>
</div>
</section>
#example-element {
color: gold;
padding: 10px;
font-size: 1.5rem;
text-align: left;
width: 100%;
}
.example-container {
border: 2px dashed #2d5ae1;
}
.example-container-bg {
background-color: #77767b;
padding: 20px;
}
This property is a shorthand for all CSS properties except for {{cssxref("unicode-bidi")}}, {{cssxref("direction")}}, and custom properties.
/* Global values */
all: initial;
all: inherit;
all: unset;
all: revert;
all: revert-layer;
The all property is specified as one of the CSS global keyword values. Note that none of these values affect the {{cssxref("unicode-bidi")}} and {{cssxref("direction")}} properties.
revert value rolls back the cascade to the user level, so that the specified values are calculated as if no author-level rules were specified for the element. For purposes of revert, the author origin includes the Override and Animation origins.revert value rolls back the cascade to the user-agent level, so that the specified values are calculated as if no author-level or user-level rules were specified for the element.revert value acts like unset.{{CSSInfo}}
{{csssyntax}}
In this example, the CSS file contains styling for the {{HTMLElement("blockquote")}} element in addition to some styling for the parent <body> element. Various outputs in the Results subsection demonstrate how the styling of the <blockquote> element is affected when different values are applied to the all property inside the blockquote rule.
<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
margin: 0;
padding: 0;
}
blockquote {
background-color: skyblue;
color: red;
}
all property<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
}
{{EmbedLiveSample("a._no_all_property", "200", "125")}}
This is the scenario in which no all property is set inside the blockquote rule. The {{HTMLElement("blockquote")}} element uses the browser's default styling which gives it a margin, together with a specific background and text color as specified in the stylesheet. It also behaves as a block element: the text that follows it is beneath it.
all: initial<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
all: initial;
}
{{EmbedLiveSample("b._all_initial", "200", "125")}}
With the all property set to initial in the blockquote rule, the {{HTMLElement("blockquote")}} element doesn't use the browser default styling anymore: it is an inline element now (initial value), its background-color is transparent (initial value), its font-size is medium, and its color is black (initial value).
all: inherit<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
all: inherit;
}
{{EmbedLiveSample("c._all_inherit", "200", "125")}}
In this case, the {{HTMLElement("blockquote")}} element doesn't use the browser default styling. Instead, it inherits style values from its parent {{HTMLElement("body")}} element: it is a block element now (inherited value), its {{cssxref("background-color")}} is #F0F0F0 (inherited value), its {{cssxref("font-size")}} is small (inherited value), and its {{cssxref("color")}} is blue (inherited value).
all: unset<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
all: unset;
}
{{EmbedLiveSample("d._all_unset", "200", "125")}}
When the unset value is applied to the all property in the blockquote rule, the {{HTMLElement("blockquote")}} element doesn't use the browser default styling. Because background-color is a non-inherited property and font-size and color are inherited properties, the <blockquote> element is an inline element now (initial value), its {{cssxref("background-color")}} is transparent (initial value), but its {{cssxref("font-size")}} is still small (inherited value), and its {{cssxref("color")}} is blue (inherited value).
all: revert<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
all: revert;
}
{{EmbedLiveSample("e._all_revert", "200", "125")}}
When the all property is set to revert in the blockquote rule, the blockquote rule is considered to be non-existent and the styling property values are inherited from the ones applied to the parent element <body>. So the <blockquote> element gets styled as a block element, with {{cssxref("background-color")}} #F0F0F0, {{cssxref("font-size")}} small, and {{cssxref("color")}} blue - all values inherited from the body rule.
all: revert-layer<blockquote id="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</blockquote>
Phasellus eget velit sagittis.
body {
font-size: small;
background-color: #f0f0f0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
all: revert-layer;
}
{{EmbedLiveSample("f._all_revert-layer", "200", "125")}}
There are no cascade layers defined in the CSS file, so the <blockquote> element inherits its style from the matching body rule. The <blockquote> element here is styled as a block element, with {{cssxref("background-color")}} #F0F0F0, {{cssxref("font-size")}} small, and {{cssxref("color")}} blue - all values inherited from the body rule. This scenario is an example of the case when all set to revert-layer behaves the same as when all is set to revert.
{{Specifications}}
{{Compat}}
CSS global keyword values: {{cssxref("initial")}}, {{cssxref("inherit")}}, {{cssxref("unset")}}, {{cssxref("revert")}}, {{cssxref("revert-layer")}}