Multiple Doctypes in a single HTML Document

前端 未结 3 495
日久生厌
日久生厌 2021-01-18 05:29

If a HTML document has two doctypes, how will the doctypes affect the rendering of the page and which doctype would the browser pick? Is having two (or more) doctypes in a s

3条回答
  •  日久生厌
    2021-01-18 05:47

    If you have multiple DOCTYPE-s in your HTML page then browser will consider first one, browser parse the DOM line by line. Once browser get DOCTYPE then it will stop looking for other doctypes and will jump to search for HTML tag.

    In the above question HTML-5 DOCTYPE is mentioned first and then HTML-4, according to this browser will render things as HTML-5 doctype

    It is better to try once in http://www.w3schools.com/ ... Try to use 'code' or 'kbd' or 'dfn' or 'samp' or 'strong' tag by mentioning both doctypes by priority.

提交回复
热议问题