Why don't self-closing script elements work?

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

What is the reason browsers do not correctly recognize:



        
12条回答
  •  执笔经年
    2020-11-21 04:50

    Difference between 'true XHTML', 'faux XHTML' and HTML as well as importance of the server-sent MIME type had been already described here well. If you want to try it out right now, here is simple editable snippet with live preview including self-closed script tag for capable browsers:

    div { display: flex; }
    div + div {flex-direction: column; }
    Mime type:

    You should see Hello, true XHTML. Nice to meet you! below textarea.

    For incapable browsers you can copy content of the textarea and save it as a file with .xhtml (or .xht) extension (thanks Alek for this hint).

提交回复
热议问题