body

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

Syntax

HTML

<body attribute-name="attribute-value"></body>

Attributes

Global

NameValueDescription
onafterprintstringHandles the event after printing
onbeforeprintstringHandles the event before printing
onbeforeunloadstringHandles the event when the page is about to be unloaded, in case the page would like to show a warning prompt
onhashchangestringHandles the event when the fragment identifier part of the document's current address changes
onmessagestringHandles the event when the object receives a message
onofflinestringHandles the event when the network connections fails
ononlinestringHandles the event when the network connections returns
onpagehidestringHandles the event when the page's entry in the session history stops being the current entry
onpageshowstringHandles the event when the page's entry in the session history becomes the current entry
onpopstatestringHandles the event when the user navigates the session history
onredostringHandles the event when the user goes forward in the undo transaction history
onresizestringHandles the event when the page is resized
onstoragestringHandles the event when storage occurs
onundostringHandles the event when the user goes backward in the undo transaction history
onunloadstringHandles the event when the page is going away

CSS

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

Examples

1 · onafterprint

2 · onbeforeprint

3 · onbeforeunload

4 · onhashchange

5 · onmessage

6 · onoffline

7 · ononline

8 · onpagehide

9 · onpageshow

10 · onpopstate

11 · onredo

12 · onresize

13 · onstorage

14 · onundo

15 · onunload

16 · CSS

head

html

!doctype

a

abbr

address

area

article

aside

audio

b

base

bdi

bdo

blockquote

br

button

canvas

caption

cite

code

col

colgroup

data

datalist

dd

del

details

dfn

dialog

div

dl

dt

em

embed

fieldset

figcaption

figure

footer

form

h1

h2

h3

h4

h5

h6

head

header

hgroup

hr

html

i

iframe

img

input

ins

kbd

label

legend

li

link

main

map

mark

menu

meta

meter

nav

noscript

object

ol

optgroup

option

output

p

param

picture

pre

progress

q

rb

rp

rt

rtc

ruby

s

samp

script

section

select

slot

small

source

span

strong

style

sub

summary

sup

table

tbody

td

template

textarea

tfoot

th

thead

time

title

tr

track

u

ul

var

video

wbr

Web Hypertext Application Technology Working Group (WHATWG)

HomeMenu