Skip to main content

HTML

Doctype

  • It must only appear once, at the top of the page (before any HTML tags)
  • The <!DOCTYPE> declaration is not case sensitive
<!DOCTYPE html> // HTML5

The doctype is used for two things:

  • Web browsers use it to determine which rendering mode they should use
    • Valid doctype triggers “Standards Mode”
      • indicates that document is coded well
      • browsers try to render the page according to the CSS specifications
    • Outdated or incomplete doctype triggers “Quirks mode”
      • assumes that document is old, backwards compatible with old practices and old browsers
      • web page will still render, but it'll take more processing power and you’ll likely get a strange or ugly result
  • Markup validators look at it to determine which rules they should check the document against