HTML - Which doctype should I use?

What is a doctype?

The doctype tells the browser which version of HTML you are using, so that your page works in the way that you designed it. Each version of HTML looks and behaves differently, so it is important to provide a doctype. If you don't include a doctype, the browser uses quirks mode. When you provide a doctype, the browser uses standards mode.

What is quirks mode?

The browser doesn't know which version of HTML you are using, so it makes a best-guess approach to understanding your page, fixing and ignoring any errors as it encounters them. It assumes that your page was written before HTML became a standard.

Browsers implement quirks mode differently -- they each have their own quirks -- so your page will work differently in each browser.

A page with a doctype will look the same in all browsers.

Common doctypes in use today


  <!DOCTYPE html>

This is the doctype to use for all new development. It is recognized by all modern browsers, and will trigger standards mode in older browsers.

HTML 4.01

  <!-- HTML 4.01 Strict -->
  <!-- HTML 4.01 Transitional -->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
  <!-- HTML 4.01 Frameset -->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "">


  <!-- XHTML 1.1 -->
  <!-- XHTML 1.1 Basic -->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "">


  <!-- XHTML 1.0 Strict-->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
  <!-- XHTML 1.0 Transitional -->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
  <!-- XHTML 1.0 Frameset -->
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "">

See also: W3C - Recommended Doctype Declarations to use in your Web document.

Ads by Google

Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath