Document structure
Document structure
Introduction
Use semantic HTML Elements for document structure. Three semantic elements are used to give overall document structure:
-
<html>
is the root of an HTML document and contains all elements except the<!DOCTYPE>
declaration. -
<head>
is the container for metadata such as document title, styles and scripts. The<head>
element is the first element in the<html>
element before the<body>
. -
<body>
defines the body or content of the HTML document. There can only be one<body>
in the document.
These elements ensure how a page is displayed is consistent across every browser.
The following example shows the semantic elements for document structure:
<!DOCTYPE html>
<html>
<head>
<title>Example accurate and meaningful title</title>
</head>
<body>
<h1>Example content heading</h1>
<p>Example content paragraph</p>
</body>
</html>
When it goes wrong
Not using the document structure elements accordingly may mean the page is not correctly rendered in every browser.
Omitting the<html>
,
<head>
and
<body>
is allowed under certain conditions in the