You are here: Reference > HTML > tags > body

body element

Browser support:
Specifies the main body of an HTML document.
The body element contains the visible content of an HTML document.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: body.

Possible members:

Attributes
Events
Styles
Pseudos
accessKey
Sets an access key to an element.
aLink
Sets the color of the active hypertext links in the entire document.
background
Sets the background picture, which will be tiled to provide the body background.
bgColor
Sets the background color.
bgProperties
Sets whether the background picture, specified by the background attribute, is fixed or scrollable.
bottomMargin
Specifies the thickness of the bottom margin in the document body.
class
Sets the style class or classes that belong to the element.
contentEditable
3
Sets whether the contents of the object are editable.
dir
Sets the text direction as related to the lang attribute.
DISABLED
Sets the state of an object for user interaction.
draggable
3.55
Sets whether an element is draggable.
HIDEFOCUS
Specifies whether a dotted rectangle (focus rectangle) is drawn around an object while it has focus.
id
Sets a unique identifier for the object.
lang
Specifies the language of the element.
language
Sets the scripting language for the current element. Use it only for the script element.
leftMargin
Sets the left margin for the document body in pixels.
link
Sets the color of the hypertext links in the entire document that have not been visited and activated yet.
name
Sets the name of an element.
NOWRAP
Specifies whether the text in a table cell can be wrapped.
rightMargin
Sets the right margin for the document body in pixels.
scroll
Sets the state of the document window's scrollbars.
spellcheck
Sets whether the automatic spellchecker is enabled.
style
Sets an inline style associated with an element.
tabIndex
Specifies the tabbing order for keyboard navigation using the TAB key.
text
Specifies the color of the text in the document body.
title
Specifies a tooltip for an element.
topMargin
Specifies the thickness of the top margin in the document body.
unSelectable
Sets whether the selection process can start in an element's content.
vLink
Sets the color of the visited hypertext links in the entire document.
xml:lang
Sets the language code of the XML document.

Example HTML code 1:

This example illustrates the use of the body element:
<html>
    <head>
        <title>My HomePage</title>
    </head>
    <body>
        The contents of the HTML document.
    </body>
</html>
Did you find this example helpful? yes no

Example HTML code 2:

This example sets the background color of the document:
<head>
    <style>
        body {
            background-color: #80a0f0;
        }
    </style>
</head>
<body>
    My background color is blue.
</body>
Did you find this example helpful? yes no

Example HTML code 3:

This example uses the scroll attribute and the overflow style property of the body to hide the scrollbars of the document in all commonly used browsers:
<head>
    <style>
        body {
            overflow: hidden;
        }
    </style>
</head>
<body scroll="no">
    <div style="width:600px; height:1000px; background-color:#a0c0a0;">
        Resize the window, the scrollbars won't be visible.
    </div>
</body>
Did you find this example helpful? yes no

Example HTML code 4:

This example is the same as the previous one, but it uses the overflow style property of the html element to hide the scrollbars of the document in all browsers:
<head>
    <style>
        html {
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div style="width:600px; height:1000px; background-color:#a0c0a0;">
        Resize the window, the scrollbars won't be visible.
    </div>
</body>
Did you find this example helpful? yes no

Example HTML code 5:

This example shows how to force the document's scrollbars to be always visible:
<head>
    <style>
        html {
            overflow: scroll;
        }
    </style>
</head>
<body>
    <div style="width:600px; background-color:#a0c0a0;">
        Resize the window, the scrollbars will be always visible.
    </div>
</body>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content