XHTML Example
Because XHTML is new and there's a clear transition period in front of us as the world makes the gradual shift from HTML to XHTML, the XHTML 1.0 standard defines three DTDs against which your document can be validated:
Strict contains no layout attributes; it's used in conjunction with a style sheet.
Transitional provides "backwards compatibility" with older browsers.
Frameset is used with HTML frames to break the display into two or more frames.
From the code below, you can see that the majority of the lines look like standard, valid HTML. The table setup, for instance, looks exactly like a standard HTML table. XML developers will be familiar with the syntax of the first few lines. The first line simply denotes the XML version being used, letting the browser know that this is an XML document to be parsed. The DOCTYPE element references the XHTML Strict DTD. The following line, also required, is used to identify the XML namespace to be used (the XHTML namespace, in this case). The rest of the code should be self-explanatory. Figure 1 shows the document loaded in Microsoft Internet Explorer.
<?xml version="1.0" encoding="UTF-9"?> <!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="eng"> <head> <title>XHTML Example</title> </head> <body> <h1>Welcome To XHTML!</h1> <p> Now, let's create our first paragraph. Note that we use opening and closing tags to encapsulate this paragraph. </p> <br/> While we're at it, how about some new lines! <br/> <br><br/> <table border="1"> <tr> <td>Row 1, Column 1</td> <td>Row 1, Column 2</td> </tr> <tr> <td>Row 2, Column 1</td> <td>Row 2, Column 2</td> </tr> </table> </body> </html>
Figure 1 The XHTML sample document.