CSS all-Eigenschaft
Die all-Eigenschaft setzt alle Eigenschaften des ausgewählten Elements zurück, mit Ausnahme von unicode-bidi und direction, die die Textausrichtung steuern.
Diese Eigenschaft gilt als Reset-Abkürzung. Im Gegensatz zu Mehrfachwert-Abkürzungen wie margin oder background verfügt sie über keine Langversion oder Untereigenschaften.
| Anfangswert | normal |
|---|---|
| Gilt für | Alle Elemente. |
| Vererbt | Nein. |
| Animierbar | Nein. |
| Version | CSS3 |
| DOM-Syntax | object.style.all = "inherit"; |
Syntax
Syntax der CSS all-Eigenschaft
css
all: initial | inherit | unset | revert | revert-layer;Beispiel für die all-Eigenschaft mit revert-Wert:
Beispiel der CSS all-Eigenschaft mit revert-Wert
html
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.example {
background-color: #8ebf42;
color: #666;
all: revert;
}
</style>
</head>
<body>
<h2>All property example</h2>
<p>Here the all: revert; is set.</p>
<div class="example"> An extrovert is a friendly person who enjoys talking to and being with other people. Extroverts love parties, talking on the phone, and meeting new people. </div>
</body>
</html>Ergebnis

Beispiel für die all-Eigenschaft mit inherit-, initial- und unset-Werten:
Beispiel der CSS all-Eigenschaft mit inherit-, initial- und unset-Werten
html
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
body {
font-size: 15px;
color: #1c87c9;
}
.example1 {
background-color: #8ebf42;
color: #666;
}
.example2 {
background-color: #8ebf42;
color: #666;
all: inherit;
}
.example3 {
background-color: #8ebf42;
color: #666;
all: initial;
}
.example4 {
background-color: #8ebf42;
color: #666;
all: unset;
}
</style>
</head>
<body>
<h2>All property example</h2>
<hr />
<p>No all property:</p>
<div class="example1"> An extrovert is a friendly person who enjoys talking to and being with other people. Extroverts love parties, talking on the phone, and meeting new people. </div>
<hr />
<p>all: inherit:</p>
<div class="example2"> An extrovert is a friendly person who enjoys talking to and being with other people. Extroverts love parties, talking on the phone, and meeting new people. </div>
<hr />
<p>all: initial:</p>
<div class="example3"> An extrovert is a friendly person who enjoys talking to and being with other people. Extroverts love parties, talking on the phone, and meeting new people. </div>
<hr />
<p>all: unset:</p>
<div class="example4"> An extrovert is a friendly person who enjoys talking to and being with other people. Extroverts love parties, talking on the phone, and meeting new people. </div>
<hr />
</body>
</html>Werte
| Wert | Beschreibung |
|---|---|
| initial | Setzt die Eigenschaft auf ihren Anfangswert zurück. |
| inherit | Erbt die Eigenschaft vom übergeordneten Element. |
| unset | Verhält sich wie inherit für vererbbare Eigenschaften und wie initial für nicht vererbbare. |
| revert | Legt ein Verhalten fest, das von der Herkunft des Stylesheets abhängt, der die Deklaration angehört. |
| revert-layer | Setzt die Eigenschaft auf den Wert zurück, der in der vorherigen Kaskadierungsebene festgelegt wurde. |
Praxis
Welche der folgenden Aussagen über CSS sind laut der Website w3docs korrekt?