上SCRIPT,STYLE和LINK元素类型的属性仍然需要? [英] Are Type Attributes on SCRIPT, STYLE, and LINK elements still needed?

查看:124
本文介绍了上SCRIPT,STYLE和LINK元素类型的属性仍然需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将看到许多网站有以下类型code的:

You will see many sites with the following type of code:

脚本元素:

<script type="text/javascript">
   //javascript here
</script>

链接元素:

<link rel="stylesheet" href="url.css" type="text/css" media="all" />

风格元素:

<style type="text/css">
   /* CSS */
</style>

我的问题是这样的:

My question is this:

键入在流行的浏览器需要的属性,今天?

Are the type attributes needed in the popular browsers today?

(热门意8+ IE,火狐,Webkit内核,Opera和Chrome浏览器)

(Popular meaning IE 8+, Firefox, Webkit, Opera and Chrome)

如果你的会发生什么不的包括他们?

注:答案需要覆盖HTML5和XHTML文档类型,如果有在两者之间行为的差

Note: The answer needs to cover both HTML5 and XHTML doctypes if there is a difference in behavior between the two.

推荐答案

总之,并不需要他们,因为 HTML5 ,但被要求 W3C 在标准的 HTML4 / XHTML

In short, they are not required since HTML5, but are required by W3C standards in HTML4/XHTML.

HTML5 键入剧本标签:

键入 - 此属性标识code嵌入的脚本语言
  一个脚本元素中或通过元素的src属性引用。
  这被指定为一个MIME类型;支持的MIME类型的例子
  包括文本/ javascript中,文本/ ECMAScript中,应用程序/ JavaScript和
  应用程序/ ECMAScript的。 如果这个属性不存在,该脚本
  视为JavaScript的。

type - This attribute identifies the scripting language of code embedded within a script element or referenced via the element’s src attribute. This is specified as a MIME type; examples of supported MIME types include text/javascript, text/ecmascript, application/javascript, and application/ecmascript. If this attribute is absent, the script is treated as JavaScript.

HTML4 XHTML 它要求的 W3C标准的。

有关风格链接 键入

HTML5 ,type属性不再是必需的。 默认值是
  文/ CSS。

In HTML5, the type attribute is no longer required. Default value is "text/css".

这篇关于上SCRIPT,STYLE和LINK元素类型的属性仍然需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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