HTML5< script>声明 [英] HTML5 <script> declarations

查看:137
本文介绍了HTML5< script>声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用HTML5在使用脚本块时声明脚本类型时,是否仍然有必要(或者甚至是很好的做法)?



例如。 < script type =text / javascript>



再加上在脚本中使用CDATA块怎么样?浏览器解析?



例如。 //<![CDATA [...〜code here〜... //]]>



任何帮助非常感谢。

解决方案

当前的HTML5草案不需要脚本标签的type属性。



HTML5中也不需要<![CDATA (无论如何都是XHTML特定的)。

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

e.g. <script type="text/javascript">

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

e.g. // <![CDATA[ ... ~code here ~... // ]]>

Any help much appreciated.

解决方案

The current draft of HTML5 doesn't require the type attribute for script tags.

Also the <![CDATA is not required in HTML5 (it was XHTML specific anyway).

这篇关于HTML5&lt; script&gt;声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆