HTML5 [removed] declarations

后端 未结 3 479
滥情空心
滥情空心 2020-12-06 09:55

Is it still necessary (or even good practice) when using HTML5 to declare the script type when using a script block?

e.g.

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 10:30

    Is it still necessary (or even good practice) when using HTML5 to declare the script type when using a script block?

    HTML 5 defines text/javascript as the default, and you'd be hard pressed to find a browser that didn't treat it as such. So you can omit it.

    Plus what about using a CDATA block in the script for browser parsing?

    Pointless unless you are writing XHTML 5 and using characters such as < or & in the script (but you should almost always be using external scripts anyway).

提交回复
热议问题