body

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

Attributes

<body attribute-name="attribute-value"></body>
Name Value Description
onafterprint string Handles the event after printing
onbeforeprint string Handles the event before printing
onbeforeunload string Handles the event when the page is about to be unloaded, in case the page would like to show a warning prompt
onhashchange string Handles the event when the fragment identifier part of the document's current address changes
onmessage string Handles the event when the object receives a message
onoffline string Handles the event when the network connections fails
ononline string Handles the event when the network connections returns
onpagehide string Handles the event when the page's entry in the session history stops being the current entry
onpageshow string Handles the event when the page's entry in the session history becomes the current entry
onpopstate string Handles the event when the user navigates the session history
onredo string Handles the event when the user goes forward in the undo transaction history
onresize string Handles the event when the page is resized
onstorage string Handles the event when storage occurs
onundo string Handles the event when the user goes backward in the undo transaction history
onunload string Handles the event when the page is going away

Global

CSS

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

Example | onafterprint

Example | onbeforeprint

Example | onbeforeunload

Example | onhashchange

Example | onmessage

Example | onoffline

Example | ononline

Example | onpagehide

Example | onpageshow

Example | onpopstate

Example | onredo

Example | onresize

Example | onstorage

Example | onundo

Example | onunload

Example | CSS

External

W3C HTML 4.01 Specification

W3C HTML5

W3C HTML 5.1