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 1108251 of <body>

  • Enlace amigable (slug) de la revisión: Web/HTML/Elemento/body
  • Título de la revisión: <body>
  • Id de la revisión: 1108251
  • Creada:
  • Creador: raecillacastellana
  • ¿Es la revisión actual?
  • Comentario
Etiquetas: 

Contenido de la revisión

{{HTMLRef}}

El Elemento HTML <body> representa el contenido de un documento HTML. Sólo puede haber un elemento <body> en un documento.

Content categories Sectioning root.
Permitted content Flow content.
Tag omission The start tag may be omitted if the first thing inside it is not a space character, comment, {{HTMLElement("script")}} element or {{HTMLElement("style")}} element. The end tag may be omitted if the body element has contents or has a start tag, and is not immediately followed by a comment.
Permitted parent elements It must be the second element of an {{HTMLElement("html")}} element.
DOM interface {{domxref("HTMLBodyElement")}}
  • The <body> element exposes the {{domxref("HTMLBodyElement")}} interface.
  • You can access the body element through the {{domxref("document.body")}} attribute.

Attributes

This element includes the global attributes.

{{htmlattrdef("alink")}} {{obsolete_inline}}
Color of text for hyperlinks when selected. This method is non-conforming, use CSS {{cssxref("color")}} property in conjunction with the {{cssxref(":active")}} pseudo-class instead.
{{htmlattrdef("background")}} {{obsolete_inline}}
URI of a image to use as a background. This method is non-conforming, use CSS {{cssxref("background")}} property on the element instead.
{{htmlattrdef("bgcolor")}} {{obsolete_inline}}
Background color for the document. This method is non-conforming, use CSS {{cssxref("background-color")}} property on the element instead.
{{htmlattrdef("bottommargin")}} {{obsolete_inline}}
The margin of the bottom of the body. This method is non-conforming, use CSS {{cssxref("margin-bottom")}} property on the element instead.
{{htmlattrdef("leftmargin")}} {{obsolete_inline}}
The margin of the left of the body. This method is non-conforming, use CSS {{cssxref("margin-left")}} property on the element instead.
{{htmlattrdef("link")}} {{obsolete_inline}}
Color of text for unvisited hypertext links. This method is non-conforming, use CSS {{cssxref("color")}} property in conjunction with the {{cssxref(":link")}} pseudo-class instead.
{{htmlattrdef("onafterprint")}}
Function to call after the user has printed the document.
{{htmlattrdef("onbeforeprint")}}
Function to call when the user requests printing of the document.
{{htmlattrdef("onbeforeunload")}}
Function to call when the document is about to be unloaded.
{{htmlattrdef("onblur")}}
Function to call when the document loses focus.
{{htmlattrdef("onerror")}}
Function to call when the document fails to load properly.
{{htmlattrdef("onfocus")}}
Function to call when the document receives focus.
{{htmlattrdef("onhashchange")}}
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")}}
Function to call when the document has finished loading.
{{htmlattrdef("onmessage")}}
Function to call when the document has received a message.
{{htmlattrdef("onoffline")}}
Function to call when network communication has failed.
{{htmlattrdef("ononline")}}
Function to call when network communication has been restored.
{{htmlattrdef("onpopstate")}}
Function to call when the user has navigated session history.
{{htmlattrdef("onredo")}}
Function to call when the user has moved forward in undo transaction history.
{{htmlattrdef("onresize")}}
Function to call when the document has been resized.
{{htmlattrdef("onstorage")}}
Function to call when the storage area has changed.
{{htmlattrdef("onundo")}}
Function to call when the user has moved backward in undo transaction history.
{{htmlattrdef("onunload")}}
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. Added the on* attributes.
{{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")}}

Fuente de la revisión

<p>{{HTMLRef}}</p>

<p>El <strong>Elemento HTML <code>&lt;body&gt;</code></strong> representa el contenido de un documento HTML. Sólo puede haber un elemento <code>&lt;body&gt;</code> en un documento.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories">Content categories</a></th>
   <td><a href="/en-US/docs/Web/HTML/Sections_and_Outlines_of_an_HTML5_document#Sectioning_roots">Sectioning root</a>.</td>
  </tr>
  <tr>
   <th scope="row">Permitted content</th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>.</td>
  </tr>
  <tr>
   <th scope="row">Tag omission</th>
   <td>The start tag may be omitted if the first thing inside it is not a space character, comment, {{HTMLElement("script")}} element or {{HTMLElement("style")}} element. The end tag may be omitted if the body element has contents or has a start tag, and is not immediately followed by a comment.</td>
  </tr>
  <tr>
   <th scope="row">Permitted parent elements</th>
   <td>It must be the second element of an {{HTMLElement("html")}} element.</td>
  </tr>
  <tr>
   <th scope="row">DOM interface</th>
   <td>{{domxref("HTMLBodyElement")}}
    <ul>
     <li>The <code>&lt;body&gt;</code> element exposes the {{domxref("HTMLBodyElement")}} interface.</li>
     <li>You can access the body element through the {{domxref("document.body")}} attribute.</li>
    </ul>
   </td>
  </tr>
 </tbody>
</table>

<h2 id="Attributes">Attributes</h2>

<p>This element includes the <a href="/en-US/docs/Web/HTML/Global_attributes">global attributes</a>.</p>

<dl>
 <dt>{{htmlattrdef("alink")}} {{obsolete_inline}}</dt>
 <dd>Color of text for hyperlinks when selected. <em>This method is non-conforming, use CSS {{cssxref("color")}} property in conjunction with the {{cssxref(":active")}} pseudo-class instead.</em></dd>
 <dt>{{htmlattrdef("background")}} {{obsolete_inline}}</dt>
 <dd>URI of a image to use as a background. <em>This method is non-conforming, use CSS {{cssxref("background")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("bgcolor")}} {{obsolete_inline}}</dt>
 <dd>Background color for the document. <em>This method is non-conforming, use CSS {{cssxref("background-color")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("bottommargin")}} {{obsolete_inline}}</dt>
 <dd>The margin of the bottom of the body. <em>This method is non-conforming, use CSS {{cssxref("margin-bottom")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("leftmargin")}} {{obsolete_inline}}</dt>
 <dd>The margin of the left of the body. <em>This method is non-conforming, use CSS {{cssxref("margin-left")}} property on the element instead.</em></dd>
 <dt>{{htmlattrdef("link")}} {{obsolete_inline}}</dt>
 <dd>Color of text for unvisited hypertext links. <em>This method is non-conforming, use CSS {{cssxref("color")}} property in conjunction with the {{cssxref(":link")}} pseudo-class instead.</em></dd>
 <dt>{{htmlattrdef("onafterprint")}}</dt>
 <dd>Function to call after the user has printed the document.</dd>
 <dt>{{htmlattrdef("onbeforeprint")}}</dt>
 <dd>Function to call when the user requests printing of the document.</dd>
 <dt>{{htmlattrdef("onbeforeunload")}}</dt>
 <dd>Function to call when the document is about to be unloaded.</dd>
 <dt>{{htmlattrdef("onblur")}}</dt>
 <dd>Function to call when the document loses focus.</dd>
 <dt>{{htmlattrdef("onerror")}}</dt>
 <dd>Function to call when the document fails to load properly.</dd>
 <dt>{{htmlattrdef("onfocus")}}</dt>
 <dd>Function to call when the document receives focus.</dd>
 <dt>{{htmlattrdef("onhashchange")}}</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")}}</dt>
 <dd>Function to call when the document has finished loading.</dd>
 <dt>{{htmlattrdef("onmessage")}}</dt>
 <dd>Function to call when the document has received a message.</dd>
 <dt>{{htmlattrdef("onoffline")}}</dt>
 <dd>Function to call when network communication has failed.</dd>
 <dt>{{htmlattrdef("ononline")}}</dt>
 <dd>Function to call when network communication has been restored.</dd>
 <dt>{{htmlattrdef("onpopstate")}}</dt>
 <dd>Function to call when the user has navigated session history.</dd>
 <dt>{{htmlattrdef("onredo")}}</dt>
 <dd>Function to call when the user has moved forward in undo transaction history.</dd>
 <dt>{{htmlattrdef("onresize")}}</dt>
 <dd>Function to call when the document has been resized.</dd>
 <dt>{{htmlattrdef("onstorage")}}</dt>
 <dd>Function to call when the storage area has changed.</dd>
 <dt>{{htmlattrdef("onundo")}}</dt>
 <dd>Function to call when the user has moved backward in undo transaction history.</dd>
 <dt>{{htmlattrdef("onunload")}}</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">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 <code>margintop</code>, <code>marginleft</code>, <code>marginright</code> and <code>marginbottom</code>. Added the <code>on*</code> attributes.</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 <code>alink</code>, <code>background</code>, <code>bgcolor</code>, <code>link</code>, <code>text</code> and <code>vlink</code> attributes.</td>
  </tr>
 </tbody>
</table>

<h2 id="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>[1] Was supported before this in Quirk Mode only.</p>

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

<ul>
 <li>{{HTMLElement("html")}}</li>
 <li>{{HTMLElement("head")}}</li>
</ul>
Revertir a esta revisión