The estate all
is a shorthand (shortcut) to get all CSS properties of the element defined by user-agent
.
For example the tag input
has some CSS attributes that are declared by user-agent
, if you want to "clear" these attributes default browser you can use the all:unset
. Or if you have one input
stylized by an external style sheet you can use the all:revert
to return the input
to the state default of user-agent
.
Is there any real usefulness to this property?
Pros and cons: A utility I see is that the CSS code gets cleaner since you will use fewer lines of code to remove all styles default. Therefore, with the all
you achieve all the properties at once, and that way you have a more streamlined code, and even your productivity can increase. The downside is that you might end up eliminating some style you wouldn’t like and will have to include it back in hand...
According to Mozilla documentation on the subject: https://developer.mozilla.org/en-US/docs/Web/CSS/all
initial
Specifies that all widget properties must be changed to their initial values.
inherit
: Specifies that all widget properties must be changed to their inherited values.
unset
: Specifies that all widget properties must be changed to their values inherited
inherit by default or for their values initial
, if they are not.
In short, the unset
can go back to the last inherited value if you have any, if you don’t have it goes to the initial values. In the example below, with the all:unset
the blockquote
will inherit the font styles of the body
, but had nothing stated in body
the blockquote
would go back to shape initial
body {
font-size: small;
background-color: #F0F0F0;
color:blue; }
blockquote {
background-color: skyblue;
color: red;
}
blockquote {
all: unset;
}
<blockquote id="quote">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</blockquote>
Phasellus eget velit sagittis.
revert
: Reverts the CSS so that a property assumes the value it would have if there were no styles at the origin of the current style (customized by the author or user-agent
)
The revert
is useful for isolating widgets
or embedded page styles components containing them, mainly when used with the property all
.
Important: The value revert
however has much more limited browser support than the other values as you can see here:
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/revert
But what’s the point?
Usually you use the all
when you want to "clean" styles default from the browser to build your own style, or how much you want some style sheet does not focus on some element, turning it to the state initial
.
See a practical example:
Cleaning up the style default of user-agent
of a input
.input-custom {
all:unset;
border: 1px solid red;
}
<input class="input-custom" placeholder="all unset" type="text">
<input class="input-custom" type="checkbox" name="" id=""><br>
<input type="text" placeholder="sem all unset">
<input type="checkbox" name="" id="">
Browser Support:
Source: https://caniuse.com/#search=all
Good question, I had already used all to answer some things here on the site, but I did not find anything exclusively about this property around here
– hugocsl
Yeah, I kept looking for a question related to that but I didn’t find anything, so I decided to make mine.
– João Pedro Schmitz
I also ended up giving a researched because I had already used it here before, but since I had nothing more specific it is always worth asking!
– hugocsl