Separating Heads from Bodies
Whenever you write a web page in XHTML, the whole of the page is contained between the opening
< html > and closing < /html > tags, just as it was in the last example. Inside the < html > element, there are
two main parts to the page:
-
The < head > element: Often referred to as the head of the page, this contains information about
the page (this is not the main content of the page). For example, it might contain a title and a
description of the page, or instructions on where a browser can find CSS rules that explain how
the document should look. It consists of the opening < head > tag, the closing < /head > tag, and
everything in between.
-
The < body > element: Often referred to as the body of the page, this contains the information
you actually see in the main browser window. It consists of the opening < body > tag, closing
< /body > tag, and everything in between.
Together, the < html > , < head > , and < body > elements make up the skeleton of an XHTML document —
they are the foundation upon which every web page is built.
Inside the < head > element of the first example page, you can see a < title > element:
< head >
< title > Popular Websites: Google < /title >
< /head >
Example
<!DOCTYPE html>
<html>
<body>
<p>
This paragraph contains a lot of lines in the source code, but the browser ignores it.
</p>
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser ignores it.
</p>
<p>
The number of lines in a paragraph depends on the size of the browser window.
If you resize the browser window, the number of lines in this paragraph will change.
</p>
</body>
</html>