html The Document Element

<html> The Document Element

This element is supported in XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, and XHTML 1.1. Here are its attributes:

  • dir Sets the direction of text that doesn't have an inherent direction in which you should read it, called directionally neutral text. You can set this attribute to LTR , for left-to-right text, or RTL , for right-to-left text. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • lang Specifies the base language used in the element. This applies only when the document is interpreted as HTML. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • xml:lang Specifies the base language for the element when the document is interpreted as XML. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • xmlns Required. Set this attribute to http://www.w3.org/1999/xhtml . (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

The document element for all XHTML elements is <html> , which is how XHTML matched the <HTML> element in HTML documents. This element must contain all the content of the document, as in this example:

 <?xml version="1.0"?>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   <head>   <title>   Welcome to my page   </title>   </head>   <body>   <h1>   Welcome to XHTML!   </h1>   </body>   </html>  

The document element is very important in XML documents, of course. Note that this is one of the big differences between XHTML and HTML: In HTML, the <HTML> tag is optional because it's the default. To be valid XHTML, a document must have a <html> element.

Of all the attributes of this element, only one is required: xmlns , which sets the XML namespace. Most XML applications set up their own namespace to avoid overlap, and XHTML is no exception; you must set the xmlns attribute to "http://www.w3.org/1999/xhtml" in XHTML documents.

This tag also supports the lang and xml:lang attributes to let you specify the language of the document. If you specify values for both these attributes, the xml:lang attribute takes precedence in XHTML.

In XHTML, the <html> element can contain a <head> and a <body> element (or a <head> and <frameset> element in the XHTML 1.0 Frameset document).



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

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