Aller au contenu

Propriété all du CSS

La propriété all réinitialise toutes les propriétés de l'élément sélectionné, à l'exception de unicode-bidi et direction, qui contrôlent la direction du texte.

Cette propriété est considérée comme un raccourci de réinitialisation. Contrairement aux raccourcis multi-valeurs comme margin ou background, elle ne possède pas de version longue ni de sous-propriétés.

Valeur initialenormal
S'applique àTous les éléments.
HéritéeNon.
AnimableNon.
VersionCSS3
Syntaxe DOMobject.style.all = "inherit";

Syntaxe

Syntaxe de la propriété all du CSS

css
all: initial | inherit | unset | revert | revert-layer;

Exemple de la propriété all avec la valeur revert :

Exemple de la propriété CSS all avec la valeur revert

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>

Résultat

Propriété all du CSS

Exemple de la propriété all avec les valeurs inherit, initial et unset :

Exemple de la propriété CSS all avec les valeurs inherit, initial et unset

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>

Valeurs

ValeurDescription
initialDéfinit la propriété à sa valeur initiale.
inheritHérite la propriété de son élément parent.
unsetSe comporte comme inherit pour les propriétés héritables et initial pour les autres.
revertSpécifie un comportement qui dépend de l'origine de la feuille de style à laquelle la déclaration appartient.
revert-layerRétablit la propriété à la valeur définie dans la couche de cascade précédente.

Pratique

Selon le site w3docs, lesquelles des affirmations suivantes sur le CSS sont vraies ?

Trouvez-vous cela utile?

Aperçu dual-run — comparez avec les routes Symfony en production.