
Originally Posted by
rb657062
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Normally, any new document should be written to a Strict document type, using the following declaration:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
The Transitional document type should be reserved for legacy documents.
the width will differ depending on which browser I use. Could anyone take the time to explain the reasoning behind this occurance?
In days gone by, browsers exhibited many rendering bugs. More recent versions have long since corrected them (though IE6 still maintains a large number). As (unfortunately) the majority of documents on the Web inadvertently rely on these bugs to display correctly, browser vendors made the decision to keep these display bugs within the code base of their browsers. However, to allow authors who know what their doing to write valid, conforming documents and to take advantage in newer features, the vendors implemented a switch using the now infamous DOCTYPE Sniff.
For a good article on DOCTYPE switching, see Activating the Right Layout Mode Using the Doctype Declaration by Henri Sivonen.
I've been exposed to this code several times, but I never understood why it mattered. I always had the impression, it was optional.
The document type declaration is (formally) mandatory, but as browsers don't implement HTML as it is specified, they will still render malformed documents. However, as the declaration places newer browsers into 'Standards' mode, continuing to omit it is usually a mistake.
Mike
Bookmarks