Body
Talk0this wiki
| Body | |
| Basic usage: | |
| |
| Spec version | 2.0 |
| Example output: | |
| This page | |
The <body></body> element surrounds all of a page's content that will actually be rendered on the web page. It is possible to specify a background color or image for the page by using the proper CSS property.
Contents |
Example code
Edit
To apply this in an HTML document, use:
<!DOCTYPE html> <html> <head> <title>The title</title> Head content </head> <body> Body content </body> </html>
Attributes
Edit
As of HTML 4.0, all presentational attributes on the body are deprected in favor of CSS.[1][2]
- Global HTML attributes
- HTML 4 & 5: onload, onunload
- Deprecated in HTML 4: background, text, link, vlink, alink
- HTML 5 only: onafterprint, onbeforeprint, onbeforeunload, onblur, onerror, onfocus, onhashchange, onmessage, onoffline, ononline, onpagehide, onpageshow, onpopstate, onredo, onresize, onscroll, onstorage, onundo
Rendering
Edit
Most graphical web browsers add an 8 pixel margin around the body contents.
Typical CSS representation:
body { display: block; margin: 8px; }
Coding rules
Edit
The <body> element is the second element inside the <html> element. (The <head> element is the first one.) Inside the <body> element, only elements from the Flow content category are allowed. The <body> element itself belongs to the Sectioning root category.
Both the start and end tags are optional. The <body> element is automatically generated when the tags are not used.
References
Edit
- ↑ http://www.w3.org/TR/REC-html40/struct/global.html#edef-BODY
- ↑ http://dev.w3.org/html5/spec/Overview.html#the-body-element-0