What is DOCTYPE?

后端 未结 8 1144
忘掉有多难
忘掉有多难 2020-11-22 16:20
  • What is DOCTYPE and why do I want to use it?
  • What are the different DOCTYPEs I can use?
  • What is the difference between standards and quirks mode, and
8条回答
  •  野性不改
    2020-11-22 16:53

    A doctype defines which version of HTML/XHTML your document uses. You would want to use a doctype so that when you run your code through validators, the validators know which version of HTML/XHTML to check against. This page provides a good overview:

    Don't forget to add a doctype

    Common doctypes you can use are listed here:

    Recommended list of DTDs

    Which doctype you should go with depends on the code you're using, but to get an idea, try running your code through the W3C validator and use the Document Type drop-down menu in the "More Options" menu to try different doctypes out.

    W3C Markup Validation Service

提交回复
热议问题