Web Programming : Understanding the Basic Document Structure

3:32:00 AM |




Understanding the Basic Document Structure
As you saw in the previous article, XHTML documents are contained between the opening <html> and closing
</html> tags (this <html> element is also known as the root element). Inside these tags, the document is
split into two sections:
. The <head> element, which contains information about the document (such as a title or a link to a
style sheet)
. The <body> element, which contains the real content of the document that you see.
This section takes a closer look at the four main elements that form the basic structure of every document:
<html>, <head>, <title>, and <body>. These four elements should appear in every XHTML
document that you write, and you will see them referred to throughout this book as the skeleton of the
document.
Remember that before an opening <html> tag, an XHTML document can contain the optional XML
declaration, and it should always contain a DOCTYPE declaration indicating which version of XHTML ituses.
The <html> Element
The <html> element is the containing element for the whole HTML or XHTML document. After the
optional XML declaration and required DOCTYPE declaration, each XHTML document should have an
opening <html> tag and each document should end with a closing </html> tag.
If you are writing Strict XHTML 1.0, the opening tag must also include something known as a namespace
identifier (this indicates that the markup in the document belongs to the XHTML 1.0 namespace).
Therefore the opening tag should look like this:
<html xmlns="http://www.w3.org/1999/xhtml">
While it is not strictly required in Transitional XHTML documents, it is a good practice to use it on all
XHTML documents.
Only two elements appear as direct children of an <html> element: <head> and <body> (although the
<head> and <body> elements will usually contain many more elements).

0 comments: