views:

128

answers:

4

I have read a number of books on DOCTYPE declaration and the three variations; strict, transitional and frameset.

but is still not able to fully understand their difference and indeed is not sure which variation I should use when creating my website; in particular i don't understand the difference between strict and transitional.

could you please advise me?

+5  A: 

Frameset is for documents that define framesets (non-frameset documents are then loaded into the frames). Frames are usually a poor design choice that cause more problems then they solve.

Transitional is, more or less, Strict plus things you shouldn't use (mostly because they have been replaced with CSS). There are a couple of exceptions, such as the start attribute which has some good arguments to support using it (but isn't often useful).

Strict is the core of HTML and is usually the best bet.

HTML 4.01 is the latest, finished version of HTML.

XHTML 1.0 is HTML 4.01 expressed in XML. It doesn't work in Internet Explorer unless you pretend it is HTML (which the text/html specification does allow).

XHTML 1.1 is XHTML 1.0 Strict plus the target attribute plus Ruby (not the programming language) plus a few other minor tweaks. There is no specification giving the OK to pretend XHTML 1.1 is HTML.

HTML 5 is a draft specification, subject to change, and with many of the interesting bits not working without JavaScript backing them up in most browsers in use today. It lacks a mature validation tool.

HTML 4.01 is generally the best bet, but XHTML 1.0 is worth considering if you have an XML toolchain in your publishing system, and HTML 5 is worth considering if you have a need for something added in it and feel the risk of living on the bleeding edge is worth it.

In short: Use HTML 4.01 Strict unless you know why you need to use something else.

David Dorward
Don't you mean "XHTML 1.1 is XHTML 1.0 Strict plus ..."?
Alohci
Whoops, yes I did.
David Dorward
A: 

First, are you using HTML or XHTML? I would recommend HTML - XHTML is a dead standard. HTML5 is the future (though who knows when that future will arrive) so I would go with HTML 4 transitional:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;

This is the closest commonly-supported doctype to HTML5. You can use features of HTML5 like the <menu> tag and it will still validate.

protonfish
I would go with HTML5 doctype: <!doctype html> Shorten and compatible with every browser. You can use HTML 4 elements with this, and don't need to worry about Strict, Transitional or Frameset.
Tae
A: 

Use the HTML5 DOCTYPE:

<!DOCTYPE HTML>

Everything else is old and busted.

HTML5 > XHTML > HTML 4

Note: The DOCTYPE is only useful for validating your document and for triggering the most standards compliant mode in modern browsers. Other than that, it's worthless. So you might as well use the most modern version (HTML5).

electronfish
... Kids... So rash.
Isaac
A: 

This will give the definitions for each variation in HTML:

http://www.w3schools.com/tags/tag_DOCTYPE.asp?PHPSESSID=1145d7fb6f2f9ef0034b49e99c599801

I have a feeling by the ones you listed your using XML, if that's the case then you probably would want to use transitional, this will allow for some small errors without messing up your page. Of course if your using frames in your page you will need to use the frame set one. For more reading the W3C Web site (http://www.w3.org/) has a lot of helpful stuff and so does Wikipedia's Doc-type article (http://en.wikipedia.org/wiki/Doctype). Hope this helps!

Blake
There are three types of page on W3Schools. Ones with almost no information, ones with massive security problems and ones with lots of errors. This is the latter. Amazingly it appears to have only one error free paragraph.
David Dorward
Transitional adds elements and attributes (mostly ones that are bad practice to use), it does not "allow errors".
David Dorward
@David Dorward...Look, if you don't like the the W3schools site that's fine, no need to rate my answer negatively because of that. They have tons of great stuff on there, maybe because they are the ones that define the standards for HTML which is what we're discussing here, remember?
Blake
What is your problem with that page? Seems to me that is answered the question about what each of the doc-type tags means.
Blake
W3Schools do NOT define the standards, the just bask in the reflected glow of having the first two letters of their name be the same as the W3C.
David Dorward
"The DTD specifies the rules for the markup language, so that the browsers can render the content correctly." — **wrong** the DTD says nothing about rendering,
David Dorward
"This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed." — **self contradictory**
David Dorward
"This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed." — **self contradictory**
David Dorward
"This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content." — **wrong** - the rules for child elements of the html element are different.
David Dorward
The XHTML 1.0 descriptions are copy/pastes of the HTML 4.01 ones have have the same problems.
David Dorward
"This DTD is equal to XHTML 1.0 Strict, but allows you to add modules (for example to provide ruby support for East-Asian languages)." — **wrong** Ruby is built in and it includes a number of things which are not in XHTML 1.0 Strict (such as `target`)
David Dorward
Oops, missed one: "The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in." — **wrong** it describes what elements are allowed where for the purposes of validation, and provides instruction on how to decode entities, the only version information in it is for human consumption.
David Dorward
Thanks for the correction, I didn't realize that the W3Schools site was not associated with the W3C.
Blake