Monday, September 13, 2010

Partial DTDs xhtml

Always include full DTDs. Some older web design packages and online resources provide
incomplete or outdated ones that can switch browsers into “quirks” mode, displaying your
site as though it were written with browser-specific, old-fashioned markup and CSS, and
rendering the page accordingly (as opposed to complying strictly with web standards. The
argument for quirks mode was largely down to backward-compatibility. For example, it
enabled Internet Explorer 6 to display CSS layouts with the box model used by Internet
Explorer 5. This type of fix is today considered archaic—see Chapter 9 for modern
methods of backward compatibility, including conditional comments. For more on quirks
mode, read Wikipedia’s article at http://en.wikipedia.org/wiki/Quirks_mode.
For the record, an example of an incomplete DTD looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"/DTD/xhtml1-transitional.dtd">
In this case, the URI (web address) is relative. Unless you have the DTD in the relevant
place on your own website, the browser will display the page this DTD is included on in
quirks mode. (And, quite frankly, if you do have the DTD on your website instead of using
the one on the W3C’s site, you are very odd indeed.) The same thing happens if you leave
out DTDs entirely. Therefore, always include a DTD and always ensure it’s complete.

No comments:

Post a Comment