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:
Strict:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Transitional:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Frameset:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
For XHTML 1.0:
Strict:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Transitional:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Frameset:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
For XHTML 1.1: XHTML 1.1 only has one DTD, but the document must be served as under the MIME types
application/xhtml+xml or
application/xml. 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:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
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.