Content-Script-Type和Content-Style-Type的意义是什么 [英] What's the point of Content-Script-Type and Content-Style-Type

查看:95
本文介绍了Content-Script-Type和Content-Style-Type的意义是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下两行:

<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />

脚本的W3文档中,在默认脚本语言:

作者应通过在HEAD中包含以下META声明,为文档中的所有脚本指定默认的脚本语言

Authors should specify the default scripting language for all scripts in a document by including the following META declaration in the HEAD

但是,它在脚本语言的本地声明中继续说:

必须为文档中的每个SCRIPT元素实例指定type属性. SCRIPT元素的type属性值将覆盖该元素的默认脚本语言.

The type attribute must be specified for each SCRIPT element instance in a document. The value of the type attribute for a SCRIPT element overrides the default scripting language for that element.

在我看来好像这里有一个超规格.为什么同时需要 meta和per- script类型声明?如果我们仍然必须分别"声明每个标签,那么强制性默认设置有什么意义呢?

Seems to me like there's an over-specification here. Why are both the meta and per-script type declarations required? What's the point of a mandatory default if we 'must' declare each tag individually anyway?

要么让默认值成为,要么只是声明每个标签都需要它自己的类型-还是这里的措辞让我绊倒了?同样,样式表也使用这种语言. >

Either let the default be the default, or just state that each tag needs it's own type - or is the wording here just getting me tripped up? The same language is used with reference to style sheets as well.

推荐答案

<script><style>元素只是向HTML添加脚本和样式的一种方法.

The <script> and <style> elements are only one way of adding scripting and styling to HTML.

对于脚本编写,我们具有事件处理程序属性,为样式化HTML 4.01定义了<link>元素,Link: HTTP标头和样式"属性.在上述每种情况下,都无需指定语言,因此后退将是Content-Script-Type和Content-Style-Type的值.

For scripting, we have event handler attributes, for styling HTML 4.01 defines the <link> element, the Link: HTTP header and the "style" attribute. In each of these cases, specifying the language is not mandated, so the fall-back would be the value of Content-Script-Type and Content-Style-Type.

例如:脚本部分显示:

未指定默认值的文档 脚本语言信息和 包含指定 内部事件脚本不正确. 用户代理仍可能尝试 解释不正确 脚本,但不是必需的. 创作工具应生成 默认脚本语言信息 帮助作者避免创建 错误的文件.

Documents that do not specify default scripting language information and that contain elements that specify an intrinsic event script are incorrect. User agents may still attempt to interpret incorrectly specified scripts but are not required to. Authoring tools should generate default scripting language information to help authors avoid creating incorrect documents.

并且样式部分有一个等效的语句:

and the styling section has an equivalent statement:

文档包含的元素 设置样式属性,但是 不要定义默认样式表 语言不正确.创作 工具应生成默认样式 工作表语言信息(通常是 META声明),以便用户 代理商不必依靠 默认为文本/css".

Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect. Authoring tools should generate default style sheet language information (typically a META declaration) so that user agents do not have to rely on a default of "text/css".

请注意,这些要求不是DTD可以表达的,因此依赖DTD的验证程序不会将违反行为标记为错误.

Note that these requirements are not DTD expressable, so validators that rely on a DTD won't flag violations as errors.

是否任何浏览器实际上都在关注设置,我都不知道.

Whether any browser actually pays any attention to the settings, I've no idea.

这篇关于Content-Script-Type和Content-Style-Type的意义是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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