What DTD/DocType should I use?
There are currently four standards in use: HTML 4.01, XHTML 1.0, XHTML 1.1 and HTML5. All of these require a different DTD to tell the browser how to render the page.
If you want to use HTML 4.01 or XHTML 1.0, there are three "flavours" of DTD: Strict, Transitional and Frameset.
Strict DTDs should be used for all new documents
. The browser will render everything in Standards Mode, the most reliable and up-to-date version. Transitional DTDs should be used only when transferring from old versions of HTML
. This is highly unlikely, and should be avoided in most circumstances. It forces the browser to guess at what the code means, using a "quirks" mode which renders the document as though it were written over a decade ago. Frameset DTDs allow frame content; this is highly discouraged and should also be avoided.
For HTML 4.01:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
For XHTML 1.0:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
For XHTML 1.1: XHTML 1.1 only has one DTD, but the document must be served as under the MIME types
. If you do not know what this means, do not use it
. Because of this requirement, XHTML 1.1 is not widely used. You may use this DTD:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
For HTML 5: HTML 5 is currently under development, but some elements have gained support in the most modern browsers. If you wish to use HTML5 and understand the major differences between that and the more-prevalent HTML 4.01, you may use this DTD:
Do not feel obliged to learn HTML5. HTML 4.01 will be around for a long, long time and is much more stable in terms of browser support.