Zusammenfassung
Das HTML <body>
Element repräsentiert den Inhalt eines HTML Dokuments. Es gibt nur ein <body>
Element in einem Dokument.
- Content categories Sectioning root.
- Erlaubter Inhalt Flow content.
- Tag PlatzierungDer Starttag darf weggelassen werden wenn das erste Ding dazwischen kein Leerzeichen, Kommentar, {{HTMLElement("script")}} Element oder {{HTMLElement("style")}} Element ist. Der Endtag kann weggelassen werden wenn das Body-Element Inhalte oder einen Starttag hat und ihm nicht sofort ein Kommentar folgt.
- Zulässige Elternelemente Es muss das zweite Element eines {{HTMLElement("html")}} Elements sein.
- DOM Schnittstelle {{domxref("HTMLBodyElement")}}
- Das
<body>
Element implementiert die {{domxref("HTMLBodyElement")}} Schnittstelle. - Sie können auf das Body-Element durch ein {{domxref("document.body")}} Attribute zugreifen.
- Das
Attribute
Dieses Element beinhaltet die global attributes.
- {{htmlattrdef("alink")}} {{obsolete_inline}}
- Textfarbe für selektierte Links. 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.
Note: Starting in Gecko 7.0 {{geckoRelease("7.0")}},
background
is no longer resolved as a URI; instead, it's treated as a simple string. - {{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")}} {{HTMLVersionInline(5)}}
- Function to call after the user has printed the document.
- {{htmlattrdef("onbeforeprint")}} {{HTMLVersionInline(5)}}
- Function to call when the user requests printing of the document.
- {{htmlattrdef("onbeforeunload")}} {{HTMLVersionInline(5)}}
- Function to call when the document is about to be unloaded.
- {{htmlattrdef("onblur")}} {{HTMLVersionInline(5)}}
- Function to call when the document loses focus.
- {{htmlattrdef("onerror")}} {{HTMLVersionInline(5)}}
- Function to call when the document fails to load properly.
- {{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}}