An ad-free and cookie-free website.
<body> tag is one of
several important tags the developer places in every HTML document.
<body> tag is the part of the
document visible to the user. So all sections, lines, colors, images,
code boxes and text are located within the
<body> element. Its primary
purpose is to act as a container for other tags.
<body> tag and its contents
are styled using CSS. Most commonly, developers use an external CSS file
and use a
<link> tag to point to
it within the
<head> tag section
of the HTML document.
Many webmasters without the budget and knowledge to fine-tune visuals and create interactive websites employ front-end frameworks, like Bootstrap. These frameworks provide the structure for how the web page is laid out; including, fonts, colors and other lightly interactive elements. Content Management Systems like WordPress offer templates for the same purpose.
<body> tag is for the visual
parts of the web page. While technically there are scnearios in which the
<body> tag and ending
</body> tag are not required,
it is advised to use both.
<body> element must be the second
element within the
<html> root tag,
<head> tag section.
As the container for the visual elements on the web page, the
<body> tag section is often the
largest section of the HTML document.
So at an absolute minimum, an HTML document will look like this.
As with all tags, Global Attributes can always be set.
Below is a series of optional attributes that can be associated with
events that occur in the
element. These will execute a specified function and can be kicked off
with or without interaction by the user.
||After the user printed a document|
||Before the user prints a document|
||Before a document is to be unloaded|
||When the document loses the focus|
||When there is an error in loading the document|
||When the document gains the focus|
||When the hash character # in the web address changed|
||When the document loaded completely|
||When a document receives a message|
||After a failure in network communication|
||After network communication has been restored|
||When a user navigates the session history|
||When a user hit redo in their transaction history|
||When the document window is resized|
||After changes are made to data storage area called Web Storage|
||When a user hit undo in their transaction history|
||When the document is unloading or closing|
In previous versions of HTML, styling attributes for the
<body> element were valid,
however with HTML5 these moved to CSS. The remaining attributes above
are associated with events.
Also, some users find the events above to be annoying, so use them sparingly.
Each user-agent (browser) has its own stylesheet per se. This dictates
how that browser styles each element by default. The Chrome browser
<body> element using
the following specifications.
The following code will run a script called
welcomeScript.js just after the
<body> tag has loaded.
For convenience it is common to include scripts used for multiple
pages of a website in a file and place it in a sub-directory off the
<body> tag is paired
with other essential tags that should be included in every HTML
We also have a growing YouTube page if you prefer video tutorials. Follow @factorpad on Twitter for reminders.
<a>tag, click Back.
<br />tag, click Next.
A newly-updated free resource. Connect and refer a friend today.