htmlcss



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.

Example code

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

As of HTML 4.0, all presentational attributes on the body are deprected in favor of CSS.[1][2]

Rendering

Most graphical web browsers add an 8 pixel margin around the body contents.

Typical CSS representation:

body {
    display: block;
    margin: 8px;
}

Coding rules

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

External links