Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which DOCTYPE declaration should we use?

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

But I am still not able to fully understand their difference and indeed am 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?

like image 659
Nayereh Avatar asked Oct 22 '10 18:10

Nayereh


People also ask

Which DOCTYPE is correct for?

Correct Option: Ddoctype html>, doctype is the very first thing to write in HTML5.

Why <! DOCTYPE is used in HTML5?

The <! DOCTYPE html> declaration is used to inform a website visitor's browser that the document being rendered is an HTML document. While not actually an HTML element itself, every HTML document should being with a DOCTYPE declaration to be compliant with HTML standards.

Should I use DOCTYPE HTML?

Yes you should put the doctype in every file. If you don't put a doctype on a document, browsers will go into quirks mode when rendering that document. And you (and your users) don't want browsers to use quirks mode to render your documents.


1 Answers

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.

(Five years ago: 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.)

Since this answer was originally written, HTML 5 has become a standard with good browser and toolchain support. It is the specification most closely aligned with how browsers actually work. An XML serialisation is available if you need XML support.

In short: Use HTML 5: <!DOCTYPE html>.

like image 105
Quentin Avatar answered Oct 04 '22 01:10

Quentin