The property all
is a shorthand (shortcut) to get all CSS properties of the element defined by user-agent
.
For example, the input
tag has some CSS attributes that are declared by user-agent
, if you want to "wipe" these default attributes of the browser you can use all:unset
. Or, if you have a% w of stylized by an external stylesheet you can use input
to return all:revert
to input
status.
Is there any real utility for this property?
Pros and cons: One utility I see is that the CSS code gets cleaner, since you'll use fewer lines of code to remove all the default . So, with user-agent
you hit all the properties at once, and in this way you have a leaner code, and even your productivity can increase. The downside is that you can end up eliminating some style you do not like and will have to include it back in hand ...
According to the Mozilla documentation on the subject: link
all
Specifies that all element properties should be changed to their initial values.
initial
: Specifies that all element properties should be changed to their inherited values.
inherit
: Specifies that all element properties should be changed to their unset
values if they inherit by default or their inherited
values, if they are not.
In short, the initial
can return to the last inherited value if it has any, if it does not, it goes back to the initial values. In the example below, with unset
all:unset
will inherit the font styles of blockquote
, but if there was nothing declared in body
then body
would return to form blockquote
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.
initial
: Reverses CSS so that a property assumes the value it would have if there were no styles in the source of the current style (customized by author or revert
)
user-agent
is useful for isolating revert
or embedded components of page styles that contain them, especially when used with the widgets
property.
Important: The all
value however has much more limited browser support than other values as you can see here:
Source: link
But what's the use?
Usually you use the revert
when u want to "clean up" styles default the browser to build their own style, or how much u want some style sheet does not fall on any element, returning it to the all
state.
See a practical example:
Clearing the default style of initial
of a user-agent
.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: link