XHTML document structure
An XHTML document consists of three main parts:
- DOCTYPE
- Head
- Body
The basic document structure is:
|
The <head>
area contains information about the document, such as ownership, copyright, and keywords; and the <body>
area contains the content of the document to be displayed.
Listing 1 shows you how this structure might be used in practice:
Listing 1. An XHTML example
|
Line 1: Since XHTML is HTML expressed in an XML document, it must include the initial XML declaration <?xml version="1.0"?>
at the top of the document.
Line 2: XHTML documents must be identified by one of three standard sets of rules. These rules are stored in a separate document called a Document Type Declaration (DTD), and are utilized to validate the accuracy of the XHTML document structure. The purpose of a DTD is to describe, in precise terms, the language and syntax allowed in XHTML.
Line 3: The second tag in an XHTML document must include the opening <html> tag with the XML namespace identified by the xmlns=http://www.w3.org/1999/xhtml
attribute. The XML namespace identifies the range of tags used by the
XHTML document. It is used to ensure that names used by one DTD don't
conflict with user-defined tags or tags defined in other DTDs.
Line 4: XHTML documents must include a full header area. This area contains the opening <head>
tag and the title tags (<title></title>
), and is then completed with the closing </head>
tag.
Line 5: XHTML documents must include opening and closing <body></body>
tags. Within these tags you can place your traditional HTML coding
tags. To be XHTML conformant, the coding of these tags must be
well-formed.
Line 6: Finally, the XHTML document is completed with the closing </html>
tag.
View XHTML: The power of two languages Discussion
Page: 1 2 3 4 5 6 7 Next Page: XHTML DTD