title The Document s Title

<title> The Document's Title

As in HTML, the <title> element contains a title for the document, stored as simple text. Most browsers will read the document's title and display it in the title bar. The title of a document is also used by search engines. This element is supported in XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, and XHTML 1.1. Here are the attributes for this element:

  • 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 an XML document. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

You use the <title> element to specify the document's title to browsers and search engines; browsers usually display the title in the title bar. The W3C XHTML DTDs say, "Exactly one title is required per document." However, the W3C XHTML validator doesn't complain if you omit a title. Nonetheless, you should put a <title> element in every document.

We saw an example <title> element at the beginning of this chapter:

 <?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> 

No major browser will react badly if you don't give a document a title. However, XHTML documents should have one, according to the W3C.

We've completed the head section of XHTML documents; next comes the body.



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

Similar book on Amazon

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