XHTML, the latest revision of HTML, adds another required element to your Web pages: the <!DOCTYPE> tag. This tag appears at the top of the file and identifies the file as an HTML document conforming to the XHTML requirements. If you were to create an XHTML-conforming document, it would look like the following: <!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>My XHTML Page</title> </head> <body> <p>This is my first XHTML page.</p> </body> </html> The <!DOCTYPE> tag has three variations: Strict, Transitional, and Frameset. You declare which one you are using in the top of the file.
Caution
You might have noticed one more change from the HTML required elements: The <html> tag has some new attributes: xmlns, xml:lang, and lang. In HTML, you only have to include the <html> tag to identify the document as an HTML file, but XHTML requires that you use the xmlns attribute to link your document to the W3C's definition of XHTML, which continues to evolve. You will learn more about this evolution and how to prepare for it in Lesson 17, "Planning for the Future." For now, just remember to include the <!DOCTYPE> tag and the full <html> tag (shown in the following sample) in all your Web pages. Figure 2.3 demonstrates how the XHTML page, created previously, would appear in the browser. <!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"> Figure 2.3. Notice that adding the XHTML declaration does not affect your page's appearance.Caution
|