Why don't self-closing script elements work?

前端 未结 12 2616
攒了一身酷
攒了一身酷 2020-11-21 04:12

What is the reason browsers do not correctly recognize:



        
12条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-21 04:56

    Internet Explorer 8 and earlier do not support XHTML parsing. Even if you use an XML declaration and/or an XHTML doctype, old IE still parse the document as plain HTML. And in plain HTML, the self-closing syntax is not supported. The trailing slash is just ignored, you have to use an explicit closing tag.

    Even browsers with support for XHTML parsing, such as IE 9 and later, will still parse the document as HTML unless you serve the document with a XML content type. But in that case old IE will not display the document at all!

提交回复
热议问题