W3docs

Selettore CSS * (asterisco)

Il selettore CSS * seleziona tutti gli elementi. Il selettore * può anche selezionare tutti gli elementi all'interno di un altro elemento. Scopri il selettore e prova gli esempi.

Il selettore * (asterisco) seleziona tutti gli elementi di un documento.

Il selettore * può anche selezionare tutti gli elementi all'interno di un altro elemento.

Versione

Selettore universale CSS2

Sintassi

**Sintassi del selettore CSS ***

* {
  css declarations;
}

Esempio del selettore *:

**Esempio di codice del selettore CSS ***

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      * {
        background-color: #8ebf42;
      }
    </style>
  </head>
  <body>
    <h2>* selector example</h2>
    <div class="example">
      <p id="example1">Lorem ipsum is simply dummy text...</p>
      <p id="example2">Lorem ipsum is simply dummy text...</p>
    </div>
    <p>Lorem ipsum is simply dummy text...</p>
  </body>
</html>

Esempio del selettore * per un elemento <div> :

**Altro esempio di codice del selettore CSS ***

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div * {
        background-color: #8ebf42;
      }
    </style>
  </head>
  <body>
    <h2>* selector example</h2>
    <div class="example">
      <p id="example1">Lorem ipsum is simply dummy text...</p>
      <span id="example2">Lorem ipsum is simply dummy text...</span>
    </div>
    <p>Lorem ipsum is simply dummy text...</p>
  </body>
</html>

Pratica

Pratica
What are the types of CSS selectors mentioned on the specified URL?
What are the types of CSS selectors mentioned on the specified URL?
Was this page helpful?