Will removing the type from a [removed] tag break in any browsers?

后端 未结 3 419
名媛妹妹
名媛妹妹 2021-01-01 21:01

In HTML5, you no longer need to include the type in a script tag when you are using JavaScript.

Are any common browsers (IE6+, Firefox 2+, Safari 3+, Opera 9+ or sim

相关标签:
3条回答
  • 2021-01-01 21:25

    going to break anywhere?

    No

    As per HTML4 specification, it won't be a valid markup only as per W3C Validator if you remove type attribute from the <script> tag although your script should still work fine across browsers.

    If you are asking in HTML5 perspective, there is no problem in leaving that out.

    0 讨论(0)
  • 2021-01-01 21:32

    No it won't break any of the popular browsers, including the ones you mention. The <script> tag will work fine without the type attribute, because all popular browsers will default to JavaScript.

    Quoting Douglas Crockford:

    type="text/javascript"

    This attribute is optional. Since Netscape 2, the default programming language in all browsers has been JavaScript. In XHTML, this attribute is required and unnecessary. In HTML, it is better to leave it out. The browser knows what to do.

    0 讨论(0)
  • 2021-01-01 21:37

    The type attribute was useful a long time ago, when JavaScript was not standardized, along with differences between different versions of the same browser. You could use other languages like vbscript, but in the real world nobody has used it in years.

    0 讨论(0)
提交回复
热议问题