Section 9.1. Minimal Document Structure


9.1. Minimal Document Structure

This markup sample shows the structure of a minimal XHTML document as specified in the XHTML 1.0 Recommendation. It provides important context to upcoming discussions of global document structure.

     <?xml version="1.0" encoding="UTF-8"?>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">       <head>         <title>Document Title</title>       </head>       <body>         <p>Content of document...</p>       </body>     </html> 

This example begins with an XML declaration that identifies the version of XML and the character encoding of the document. XML declarations are encouraged for XHTML documents; however, they are not required when the character encoding is the UTF-8 default as in the above example. Because XML declarations are problematic for current browsers as of this writing, even those that are standards-compliant, they are generally omitted.


Now, take a closer look at the four major components of XHTML (and HTML) documents.


Document type declaration

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

The document type (DOCTYPE) declaration tells the browser which DTD to use to parse the document. This example specifies XHTML Strict. If this example were an HTML document, it would use one of the HTML DTDs. The upcoming See Document Type Declaration." section provides more information on the DTD options and uses for this information.


Root element

     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">...          </html> 

html is the root element for all HTML and XHTML documents. The html element and its declarative attributes shown here are discussed in the upcoming section, "The Root Element."


Document header

     <head>        <title>Document Title</title>     </head> 

The head element, or header, contains information about the document that is not considered part of the document content. The header must include a descriptive title in order to validate. Document headers are covered in more detail later in this chapter.


Document body

     <body>         Content of Document...     </body> 

The body element contains all of the content of the documentthe part that displays in the browser window or is spoken in a speech browser. The body of an (X)HTML document might consist of just a few paragraphs of text, a single image, or a complex combination of text, images, tables, and multimedia objects. What you put on the page is up to you.




Web Design in a Nutshell
Web Design in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009879
EAN: 2147483647
Year: 2006
Pages: 325

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net