| Home Web | Top Bottom | Contents Prev Next |
The very first thing that should appear in each HTML file is a DOCTYPE line. DOCTYPE indicates which version of HTML or XHTML you're using.
|
The DOCTYPE line itself is not HTML code and doesn't follow the same format as HTML code. It's purpose is to identify which version of HTML you're using. The DOCTYPE line is optional. Until quite recently, no browsers have cared whether or not you include a DOCTYPE line. DOCTYPE has been used by HTML validators to determine what rules to follow in analyzing the correctness of your code. If DOCTYPE is missing, these validators usually assume that your code is HTML 3.2. Two recent browsers Netscape 6 and the Mac version of IE 5 are changing that. These two browsers are the first that attempt to follow W3C standards for interpreting HTML/CSS code using full CSS rules for formatting. These rules require some slight differences in how compliant pages are displayed versus the ways older non-compliant pages are displayed. Both browsers have a standards mode in which the new rules are applied and a quirks mode in which the browser uses the older formatting rules for legacy HTML pages. |
It would have been nice if the DOCTYPE line could have been something simple such as:
<!DOCTYPE HTML 4.0 Transitional> (This won't work!!!)
But, alas, we're saddled with a much more complicated looking and case-sensitive line. You'll want to choose the DOCTYPE you want to use and just copy-and-paste it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
(HTML 3.2 without URI)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
(HTML 4.0 transitional without URI)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
(HTML 4.01 transitional without URI)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
(HTML 4.0 transitional with URI)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
(HTML 4.01 transitional with URI)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
(HTML 4.0 strict without URI)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
(HTML 4.01 strict without URI)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
(XHTML 1.0 transitional without URI)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
(XHTML 1.0 strict without URI)
|
In these pages, I'll be presenting transitional HTML 4.01 and XHTML 1.0. I recommend that you use the DOCTYPE for HTML 4.01 transitional without the URI, which I've shown in bold. This doctype will trigger the quirks mode display in both Netscape 6 and Mac IE 5. I'll point out which features are deprecated and which can be used in strict HTML. I will encourage you to stick to the features that are supported in strict as much as possible, and I will sometimes ask you to validate your code in strict as well as in transitional. |
These are the rules that Netscape 6 and Mac IE 5 use for deciding whether to use standards mode or quirks mode:
Standards mode is chosen if:
- The doctype specifies HTML or XHTML strict, or
- The doctype specifies HTML 4.01 or XHTML 1.0 transitional and a URI is included, or
- IE only: The doctype specifies HTML 4.0 transitional and a URI is included. Netscape 6 chooses quirks mode for this doctype.
Quirks mode is chosen if:
- No doctype is included, or
- The doctype specifies a version of HTML earlier than 4.0, or
- The doctype specifies HTML 4.0/4.01 or XHTML 1.0 transitional and no URI is included, or
- Netscape 6 only: The doctype specifies HTML 4.0 transitional and a URI is included. Mac IE 5 chooses standards mode for this doctype.
HTML 4.01 was a very minor revision to HTML 4.0. It's purpose was to restore a couple of items that had been accidentally omitted from HTML 4.0.
| Home Web | Top Bottom | Contents Prev Next |