Tag HTML <corpo>


Esempio

Un semplice documento HTML:

<html>
<head>
  <title>Title of the document</title>
</head>

<body>
  <h1>This is a heading</h1>
  <p>This is a paragraph.</p>
</body>

</html>

Altri esempi "Provalo da solo" di seguito.


Definizione e utilizzo

Il <body>tag definisce il corpo del documento.

L' <body>elemento contiene tutto il contenuto di un documento HTML, come titoli, paragrafi, immagini, collegamenti ipertestuali, tabelle, elenchi, ecc.

Nota: può esserci un solo <body> elemento in un documento HTML.


Supporto browser

Element
<body> Yes Yes Yes Yes Yes

Attributi globali

Il <body>tag supporta anche gli attributi globali in HTML .


Attributi dell'evento

Il <body>tag supporta anche gli attributi dell'evento in HTML .



Altri esempi

Esempio

Aggiungi un'immagine di sfondo a un documento (con CSS):

<html>
<head>
<style>
body {
  background-image: url(w3s.png);
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>

Esempio

Imposta il colore di sfondo di un documento (con CSS):

<html>
<head>
<style>
body {
  background-color: #E6E6FA;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>

Esempio

Imposta il colore del testo in un documento (con CSS):

<html>
<head>
<style>
body {
  color: green;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>
</html>

Esempio

Imposta il colore dei link non visitati in un documento (con CSS):

<html>
<head>
<style>
a:link {
  color:#0000FF;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

Esempio

Imposta il colore dei link attivi in ​​un documento (con CSS):

<html>
<head>
<style>
a:active {
  color:#00FF00;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

Esempio

Imposta il colore dei link visitati in un documento (con CSS):

<html>
<head>
<style>
a:visited {
  color:#FF0000;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

Pagine correlate

Esercitazione HTML: Elementi HTML

Riferimento HTML DOM: Body Object

Riferimento HTML DOM: proprietà document.body


Impostazioni CSS predefinite

La maggior parte dei browser visualizzerà l' <body>elemento con i seguenti valori predefiniti:

Esempio

body {
  display: block;
  margin: 8px;
}

body:focus {
  outline: none;
}