What is DOCTYPE?

后端 未结 8 1195
忘掉有多难
忘掉有多难 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:36

    A doctype is a document that describes how the contents of a xhtml-like document can look like (like a webpage). Note: this defines only the syntax of said page, the rendering of the page is NOT defined by the DTD!

    For example, a doctype could define how the

    -tag can look like - which attributes it accepts, and which values/valuetypes are accepted for each attribute. Think of it as a lexicon for your current webpage.

    Wikipedia has an informative page on the various Doctypes that are in common use. Mind you - there's nothing stopping you from creating your own doctype. The chances are, however, that the browser probably doesn't know how to render your document.

    Which DTD to use depends on what you are going to write. XHTML has a whole different DTD than HTML, for example.

    提交回复
    热议问题