Zum Inhalt springen

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.

Anfangswertnormal
Gilt fürAlle Elemente.
VererbtNein.
AnimierbarNein.
VersionCSS3
DOM-Syntaxobject.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

CSS all Property

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

WertBeschreibung
initialSetzt die Eigenschaft auf ihren Anfangswert zurück.
inheritErbt die Eigenschaft vom übergeordneten Element.
unsetVerhält sich wie inherit für vererbbare Eigenschaften und wie initial für nicht vererbbare.
revertLegt ein Verhalten fest, das von der Herkunft des Stylesheets abhängt, der die Deklaration angehört.
revert-layerSetzt 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?

Finden Sie das nützlich?

Dual-run-Vorschau — vergleichen Sie mit den Symfony-Routen live.