Why don't self-closing script elements work?

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

What is the reason browsers do not correctly recognize:



        
12条回答
  •  攒了一身酷
    2020-11-21 04:39

    Internet Explorer 8 and older don't support the proper MIME type for XHTML, application/xhtml+xml. If you're serving XHTML as text/html, which you have to for these older versions of Internet Explorer to do anything, it will be interpreted as HTML 4.01. You can only use the short syntax with any element that permits the closing tag to be omitted. See the HTML 4.01 Specification.

    The XML 'short form' is interpreted as an attribute named /, which (because there is no equals sign) is interpreted as having an implicit value of "/". This is strictly wrong in HTML 4.01 - undeclared attributes are not permitted - but browsers will ignore it.

    IE9 and later support XHTML 5 served with application/xhtml+xml.

提交回复
热议问题