jump

HTML: The Markup Language Reference

bodydocument body # T

The body element represents the body of a document (as opposed to the document’s metadata).

Permitted contents #

Permitted attributes #

global attributes
Any attributes permitted globally.
onafterprint = string NEW #
User printed current document.
onbeforeprint = string NEW #
User requested printing of current document.
onbeforeunload = string NEW #
Document is about to be unloaded.
onblur = string #
Document lost focus.
onerror = string NEW #
Document failed to load properly.
onfocus = string #
Document received focus.
onhashchange = string NEW #
Fragment identifier part of the document’s current address changed.
onload = string #
Document finished loading.
onmessage = string NEW #
Document received a message.
onoffline = string NEW #
Network connections failed.
ononline = string NEW #
Network connections returned.
onpopstate = string NEW #
User navigated session history.
onredo = string NEW #
User went forward in undo transaction history.
onresize = string NEW #
Document view was resized.
onstorage = string NEW #
Storage area changed.
onundo = string NEW #
User went backward in undo transaction history.
onunload = string #
Document is going away.

Additional constraints and admonitions #

Tag omission #

A body element’s start tag may be omitted if the first thing inside the body element is not a space character or a comment, except if the first thing inside the body element is a script or style element.

A body element’s end tag may be omitted if the body element is not immediately followed by a comment and the element is either not empty or its start tag has not been omitted.

Permitted parent elements #

html

DOM interface #

interface HTMLBodyElement : HTMLElement {
           attribute Function onafterprint;
           attribute Function onbeforeprint;
           attribute Function onbeforeunload;
           attribute Function onblur;
           attribute Function onerror;
           attribute Function onfocus;
           attribute Function onhashchange;
           attribute Function onload;
           attribute Function onmessage;
           attribute Function onoffline;
           attribute Function ononline;
           attribute Function onpopstate;
           attribute Function onpagehide;
           attribute Function onpageshow;
           attribute Function onredo;
           attribute Function onresize;
           attribute Function onscroll;
           attribute Function onstorage;
           attribute Function onundo;
           attribute Function onunload;
};

Typical default display properties #

body {
display: block;
margin: 8px; }
body:focus {
outline: none; }