Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 783773 of <body>

  • Slug della versione: Web/HTML/Element/body
  • Titolo della versione: <body>
  • ID versione: 783773
  • Data di creazione
  • Autore: nicolo-ribaudo
  • Versione corrente? No
  • Commento

Contenuto della versione

Sommario

L'elemento HTML <body> rappresenta il contenuto di un documento HTML. Può essere presente solo un elemento <body> in un documento.

  • Categorie di contenuto Sezioni principali.
  • Contenuti permessi Contenuti di flusso.
  • Omissione del tagIl tag iniziale puù essere omesso se la prima cosa all'interno di esso non è uno spazio, un commento, un elemento {{HTMLElement("script")}} o un elemento {{HTMLElement("style")}}. Il tag finale può essere omesso se l'elemento <body> ha dei contenuti o ha il tag iniziale che non sia immediatamente seguito da un commento.
  • Elementi genitore permessiDeve essere il secondo elemento figlio di un elemento {{HTMLElement("html")}}.
  • Interfaccia DOM {{domxref("HTMLBodyElement")}}
    • L'elemento <body> espone l'interfaccia {{domxref("HTMLBodyElement")}}.
    • Puoi accedere all'elemento <body> di una pagina attraverso {{domxref("document.body")}}.

Attributi

Questo elemento include gli attributi globali.

{{htmlattrdef("alink")}} {{obsolete_inline}}
Il colore del testo dei link quando vengono selezionati. Questo metodo non è conforme, usa la proprietà CSS {{cssxref("color")}} insieme alla pseudo-classe {{cssxref(":active")}} sugli elementi <a>​.
{{htmlattrdef("background")}} {{obsolete_inline}}
L'URI di un'immagine da usare come sfondo. Questo metodo non è conforme, usa la proprietà CSS {{cssxref("background")}} sull'elemento <body>.
Nota: A partire da Gecko 7.0 {{geckoRelease("7.0")}}, background non è più trattato come URI, ma come una semplice stringa.
{{htmlattrdef("bgcolor")}} {{obsolete_inline}}
Il colore di sfondo del documento. Questo metodo non è conforme, usa la proprietà CSS {{cssxref("background-color")}} sull'elemento <body>.
{{htmlattrdef("bottommargin")}} {{obsolete_inline}}
Il margine inferiore del corpo del documento. Questo metodo non è conforme, usa la proprietà CSS {{cssxref("margin-bottom")}} sull'elemento <body>.
{{htmlattrdef("leftmargin")}} {{obsolete_inline}}
Il margine sinistro del corpo del documento. Questo metodo non è conforme, usa la proprietà CSS {{cssxref("margine-left")}} sull'elemento <body>.
{{htmlattrdef("link")}} {{obsolete_inline}}
Il colore del testo dei link non ancora visitati. Questo metodo non è conforme, usa la proprietà CSS {{cssxref("color")}} insieme alla pseudo-classe {{cssxref(":link")}} sugli elementi <a>.
{{htmlattrdef("onafterprint")}} {{HTMLVersionInline(5)}}
Una funzione da richiamare dopo che l'utente abbia stampato il documento.
{{htmlattrdef("onbeforeprint")}} {{HTMLVersionInline(5)}}
Una funzione da chiamare subito prima che il documento venga stampato.
{{htmlattrdef("onbeforeunload")}} {{HTMLVersionInline(5)}}
Una funzione da chiamare quando il documento sta per essere chiuso.
{{htmlattrdef("onblur")}} {{HTMLVersionInline(5)}}
Una funzione da chiamare quando l'utente non è più sul documento.
{{htmlattrdef("onerror")}} {{HTMLVersionInline(5)}}
Funzione da chiamare quando il documento non riesce a caricarsi correttamente.
{{htmlattrdef("onfocus")}} {{HTMLVersionInline(5)}}
Function to call when the document receives focus.
{{htmlattrdef("onhashchange")}} {{HTMLVersionInline(5)}}
Function to call when the fragment identifier part (starting with the hash ('#') character) of the document's current address has changed.
{{htmlattrdef("onlanguagechange")}} {{experimental_inline}}
Function to call when the preferred languages changed.
{{htmlattrdef("onload")}} {{HTMLVersionInline(5)}}
Function to call when the document has finished loading.
{{htmlattrdef("onmessage")}} {{HTMLVersionInline(5)}}
Function to call when the document has received a message.
{{htmlattrdef("onoffline")}} {{HTMLVersionInline(5)}}
Function to call when network communication has failed.
{{htmlattrdef("ononline")}} {{HTMLVersionInline(5)}}
Function to call when network communication has been restored.
{{htmlattrdef("onpopstate")}} {{HTMLVersionInline(5)}}
Function to call when the user has navigated session history.
{{htmlattrdef("onredo")}} {{HTMLVersionInline(5)}}
Function to call when the user has moved forward in undo transaction history.
{{htmlattrdef("onresize")}} {{HTMLVersionInline(5)}}
Function to call when the document has been resized.
{{htmlattrdef("onstorage")}} {{HTMLVersionInline(5)}}
Function to call when the storage area has changed.
{{htmlattrdef("onundo")}} {{HTMLVersionInline(5)}}
Function to call when the user has moved backward in undo transaction history.
{{htmlattrdef("onunload")}} {{HTMLVersionInline(5)}}
Function to call when the document is going away.
{{htmlattrdef("rightmargin")}} {{obsolete_inline}}
The margin of the right of the body. This method is non-conforming, use CSS {{cssxref("margin-right")}} property on the element instead.
{{htmlattrdef("text")}} {{obsolete_inline}}
Foreground color of text. This method is non-conforming, use CSS {{cssxref("color")}} property on the element instead.
{{htmlattrdef("topmargin")}} {{obsolete_inline}}
The margin of the top of the body. This method is non-conforming, use CSS {{cssxref("margin-top")}} property on the element instead.
{{htmlattrdef("vlink")}} {{obsolete_inline}}
Color of text for visited hypertext links. This method is non-conforming, use CSS {{cssxref("color")}} property in conjunction with the {{cssxref(":visited")}} pseudo-class instead.

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', 'sections.html#the-body-element', '<body>')}} {{Spec2('HTML WHATWG')}} Changed the list of non-conforming features.
{{SpecName('HTML5 W3C', 'sections.html#the-body-element', '<body>')}} {{Spec2('HTML5 W3C')}} Obsoleted the formerly deprecated attributes. Defined the behavior of the non-conforming and never standardized margintop, marginleft, marginright and marginbottom.
{{SpecName('HTML4.01', 'struct/global.html#h-7.5.1', '<body>')}} {{Spec2('HTML4.01')}} Deprecated the alink, background, bgcolor, link, text and vlink attributes.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
onlanguagechange {{CompatUnknown}} {{CompatGeckoDesktop("32")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
bottommargin, leftmargin, rightmargin, topmargin {{obsolete_inline}} {{CompatVersionUnknown}} {{CompatGeckoDesktop("35")}} [1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
onlanguagechange {{CompatUnknown}} {{CompatGeckoMobile("32")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
bottommargin, leftmargin, rightmargin, topmargin {{obsolete_inline}} {{CompatVersionUnknown}} {{CompatGeckoMobile("35")}} [1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

[1] Was supported before this in Quirk Mode only.

See also

  • {{HTMLElement("html")}}
  • {{HTMLElement("head")}}
{{HTMLRef}}

Sorgente della versione

<h2 id="Sommario">Sommario</h2>

<p>L'<strong>elemento HTML <code>&lt;body&gt;</code></strong> rappresenta il contenuto di un documento HTML. Può essere presente solo un elemento <code>&lt;body&gt;</code> in un documento.</p>

<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/Web/HTML/Content_categories">Categorie di contenuto</a></dfn> <a href="/en-US/docs/Web/HTML/Sections_and_Outlines_of_an_HTML5_document#Sectioning_roots">Sezioni principali</a>.</li>
 <li><dfn>Contenuti permessi</dfn> <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Contenuti di flusso</a>.</li>
 <li><dfn>Omissione del tag</dfn>Il tag iniziale puù essere omesso se la prima cosa all'interno di esso non è uno spazio, un commento, un elemento {{HTMLElement("script")}} o un elemento {{HTMLElement("style")}}. Il tag finale può essere omesso se l'elemento <code>&lt;body&gt;</code> ha dei contenuti o ha il tag iniziale che non sia immediatamente seguito da un commento.</li>
 <li><dfn>Elementi genitore permessi</dfn>Deve essere il secondo elemento figlio di un elemento {{HTMLElement("html")}}.</li>
 <li><dfn>Interfaccia DOM</dfn> {{domxref("HTMLBodyElement")}}
  <ul>
   <li>L'elemento&nbsp;<code>&lt;body&gt;</code>&nbsp;espone l'interfaccia {{domxref("HTMLBodyElement")}}.</li>
   <li>Puoi accedere all'elemento&nbsp;<code>&lt;body&gt;</code>&nbsp;di una pagina attraverso&nbsp;{{domxref("document.body")}}.</li>
  </ul>
 </li>
</ul>

<h2 id="Attributi">Attributi</h2>

<p>Questo elemento include gli&nbsp;<a href="/en-US/docs/Web/HTML/Global_attributes">attributi globali</a>.</p>

<dl>
 <dt>{{htmlattrdef("alink")}} {{obsolete_inline}}</dt>
 <dd>Il colore del testo dei link quando vengono selezionati. <em>Questo metodo non è conforme, usa la proprietà CSS {{cssxref("color")}} insieme alla pseudo-classe {{cssxref(":active")}}&nbsp;sugli elementi&nbsp;<code>&lt;a&gt;</code>​.</em></dd>
 <dt>{{htmlattrdef("background")}} {{obsolete_inline}}</dt>
 <dd>L'URI di un'immagine da usare come sfondo.&nbsp;<em>Questo metodo non è conforme, usa la proprietà CSS {{cssxref("background")}} sull'elemento&nbsp;<code>&lt;body&gt;</code>.</em>
 <div class="note"><strong>Nota:</strong>&nbsp;A partire da Gecko 7.0 {{geckoRelease("7.0")}},&nbsp;<code>background</code>&nbsp;non è più trattato come URI, ma come una semplice stringa.</div>
 </dd>
 <dt>{{htmlattrdef("bgcolor")}} {{obsolete_inline}}</dt>
 <dd>Il colore di sfondo del documento.&nbsp;<em>Questo metodo non è conforme, usa la proprietà CSS {{cssxref("background-color")}} sull'elemento&nbsp;<code>&lt;body&gt;</code>.</em></dd>
 <dt>{{htmlattrdef("bottommargin")}} {{obsolete_inline}}</dt>
 <dd>Il margine inferiore del corpo del documento.&nbsp;<em>Questo metodo non è conforme, usa la proprietà CSS {{cssxref("margin-bottom")}} sull'elemento&nbsp;<code>&lt;body&gt;</code>.</em></dd>
 <dt>{{htmlattrdef("leftmargin")}} {{obsolete_inline}}</dt>
 <dd>Il margine sinistro del corpo del documento.&nbsp;<em>Questo metodo non è conforme, usa la proprietà CSS {{cssxref("margine-left")}} sull'elemento&nbsp;<code>&lt;body&gt;</code>.</em></dd>
 <dt>{{htmlattrdef("link")}} {{obsolete_inline}}</dt>
 <dd>Il colore del testo dei link non ancora visitati.&nbsp;<em>Questo metodo non è conforme, usa la proprietà CSS {{cssxref("color")}} insieme alla pseudo-classe {{cssxref(":link")}} sugli elementi <code>&lt;a&gt;</code>.</em></dd>
 <dt>{{htmlattrdef("onafterprint")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Una funzione da richiamare dopo che l'utente abbia stampato il documento.</dd>
 <dt>{{htmlattrdef("onbeforeprint")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Una funzione da chiamare subito prima che il documento venga stampato.</dd>
 <dt>{{htmlattrdef("onbeforeunload")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Una funzione da chiamare quando il documento sta per essere chiuso.</dd>
 <dt>{{htmlattrdef("onblur")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Una funzione da chiamare quando l'utente non è più sul documento.</dd>
 <dt>{{htmlattrdef("onerror")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Funzione da chiamare quando il documento non riesce a caricarsi correttamente.</dd>
 <dt>{{htmlattrdef("onfocus")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the document receives focus.</dd>
 <dt>{{htmlattrdef("onhashchange")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the fragment identifier part (starting with the hash (<code>'#'</code>) character) of the document's current address has changed.</dd>
 <dt>{{htmlattrdef("onlanguagechange")}} {{experimental_inline}}</dt>
 <dd>Function to call when the preferred languages changed.</dd>
 <dt>{{htmlattrdef("onload")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the document has finished loading.</dd>
 <dt>{{htmlattrdef("onmessage")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the document has received a message.</dd>
 <dt>{{htmlattrdef("onoffline")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when network communication has failed.</dd>
 <dt>{{htmlattrdef("ononline")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when network communication has been restored.</dd>
 <dt>{{htmlattrdef("onpopstate")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the user has navigated session history.</dd>
 <dt>{{htmlattrdef("onredo")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the user has moved forward in undo transaction history.</dd>
 <dt>{{htmlattrdef("onresize")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the document has been resized.</dd>
 <dt>{{htmlattrdef("onstorage")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the storage area has changed.</dd>
 <dt>{{htmlattrdef("onundo")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the user has moved backward in undo transaction history.</dd>
 <dt>{{htmlattrdef("onunload")}} {{HTMLVersionInline(5)}}</dt>
 <dd>Function to call when the document is going away.</dd>
 <dt>{{htmlattrdef("rightmargin")}} {{obsolete_inline}}</dt>
 <dd>The margin of the right of the body. <em>This method is non-conforming, use CSS {{cssxref("margin-right")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("text")}} {{obsolete_inline}}</dt>
 <dd>Foreground color of text. <em>This method is non-conforming, use CSS {{cssxref("color")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("topmargin")}} {{obsolete_inline}}</dt>
 <dd>The margin of the top of the body. <em>This method is non-conforming, use CSS {{cssxref("margin-top")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("vlink")}} {{obsolete_inline}}</dt>
 <dd>Color of text for visited hypertext links. <em>This method is non-conforming, use CSS {{cssxref("color")}} property in conjunction with the {{cssxref(":visited")}} pseudo-class instead.</em></dd>
</dl>

<h2 id="Specifications" name="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'sections.html#the-body-element', '&lt;body&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Changed the list of non-conforming features.</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'sections.html#the-body-element', '&lt;body&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>Obsoleted the formerly deprecated attributes. Defined the behavior of the non-conforming and never standardized <strong>margintop</strong>, <strong>marginleft</strong>, <strong>marginright</strong> and <strong>marginbottom</strong><strong>.</strong></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/global.html#h-7.5.1', '&lt;body&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td>Deprecated the <strong>alink</strong>, <strong>background</strong>, <strong>bgcolor</strong>, <strong>link</strong>, <strong>text</strong> and <strong>vlink</strong> attributes.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>1.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>onlanguagechange</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("32")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>bottommargin</code>, <code>leftmargin</code>, <code>rightmargin</code>, <code>topmargin</code> {{obsolete_inline}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("35")}} [1]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>onlanguagechange</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("32")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>bottommargin</code>, <code>leftmargin</code>, <code>rightmargin</code>, <code>topmargin</code> {{obsolete_inline}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("35")}} [1]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p name="See_also">[1] Was supported before this in Quirk Mode only.</p>

<h2 id="See_also" name="See_also">See also</h2>

<ul>
 <li>{{HTMLElement("html")}}</li>
 <li>{{HTMLElement("head")}}</li>
</ul>

<div>{{HTMLRef}}</div>
Ripristina questa versione