![]() |
|
Every XHTML document is created based upon the rules specified in the XHTML DTD (document type definition). Here is an example: <?xml version="1.0" encoding="UTF-8"?> <!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/xhtml" xml:lang="en" lang="en"> <head> <title>Ann's idiot guide to xhtml</title> </head> <body> Blah, Blah, Blah </body> </html> It looks quite similar to HTML but there are a few extra things to know. The first line, bracketed by <? and ?>, tells the browser that your page will be based upon a DTD written using XML 1.0 with a standard character encoding. This is an optional line at the moment. The next line is the doctype declaration. You must have this declaration on every XHTML page just before the <html> tag. The purpose of the doctype declaration is to specify which Document Type Definition (DTD) the page uses. A DTD specifies what is legal syntax in XHTML and what isn't. It contains the names and attributes of all of the possible tags that you can use in your markup. Newer browsers will usually have the latest specs written into their DTDs. Your XHTML documents must refer to one of the three XHTML DTDs: Strict, Transitional, or Frameset. The XHTML DTDs are more or less the same as the existing HTML ones. Finally, the lang and xmlns attributes in the <html> tag tell the browser the language you'll be using and the namespace in which to find all the tags in your document. Namespaces tell the browser that the names of all the tags in your document can be found in the XHTML DTD. An XHTML page must be well formed and valid. This means, in essence, that the page must conform to the rules and syntax of XHTML (well formed) and the tags and attributes on the page must match the grammar and rules of the DTD (valid). |
More information What does an XHTML page look like? |