Forum Moderators: open
Is this the right choice for my doctype?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
or would this is better? I'm confused!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
or
simply:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
If you omit the url, IE, and possibly other browsers will render the page in quirks mode. Many pages will render identically, the main difference is the box-model. In quirks mode, height and width define the outermost area (and include the margin, border and padding) but in standards mode, height and width define the dimensions of innermost area, i.e. the canvas in which text and/or images are rendered.
Think of it like a painting - when you specify a size, does it include or exclude the frame?
Kaled.
See post #2 for your answer.
I would go with first option.
It is my understanding that the transitional doctype was defined specifically as an upgrade path. Since it is clear that existing code is being upgraded, why not use the right tool for the job?
If anyone out there can state one definitive advantage to using the strict doctype, I'll be impressed, however, in many cases, both will work identically.
Kaled.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> If you have a full CSS-driven (table-less) layout, then you should usually choose this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> If you use the shortened transitional version without the URL, you will trigger "quirks mode" in modern browsers (IE6, Firefox, Opera...). See our library thread Quirks mode versus Standards mode [webmasterworld.com] for further information. In the long-run, it is a good idea to always use a standards-compliant mode in the browser rather than relying on the quirks-mode behavior which is a continuation of established rendering bugs in older browsers all long since disappeared from the scene.
The "full" transitional doctype will trigger an "Almost Standards Mode" in Firefox (and other Gecko-based browsers). The difference between "Almost Standards" and "Standards" relates to default line height and margin settings in tables, hence the recommendation to use transitional for tables-based layouts. You may find that the Strict doctype will work just fine too for a tables-based layout, assuming you have no deprecated markup on the page.
So the advantages of using HTML 4.01 Strict are that you ensure that you are using the full standards mode in all modern browsers, and that it will push you into using CSS rather than deprecated presentational markup in your document.
Of course, choosing the right doctype is just one step - making sure your document is error-free by using the HTML validator [validator.w3.org] is another vital step.