除了text / css之外还有样式类型吗? [英] Is there a style type besides text/css?
问题描述
我看到当定义一个css部分时
I see that when defining a css section it's always
<style type="text/css">
</style>
还有什么可以吗?只是好奇。
Is there anything else it could be? Just curious.
推荐答案
HTML 4和5保留了其他类型的可能性,但不要指定除text / css。在实践中,我从来没有遇到过使用text / css的情况。为此,HTML5规范使type属性可选。如果省略,则使用默认类型text / css。请参阅样式标签规范详细信息:
HTML 4 and 5 leave open the possibility of other types, but do not specify any besides "text/css". In practice, I have never encountered a case where anything but "text/css" is used. For this reason, the HTML5 specification made the type attribute optional. If it is omitted, the default type "text/css" is used. See the style tag specification for details:
type属性提供样式语言。如果属性为
,则其值必须是指定样式
语言的有效MIME类型。不能指定charset参数。类型属性的默认
值是text / css,如果属性是
,则使用缺省值。 RFC2318
在HTML 4文档中,必须指定type属性。 规范不限制可以使用的值:
In HTML 4 documents, the type attribute must be specified. The specification does not limit the values that can be used:
此属性指定元素的
内容的样式表语言,并覆盖默认样式表语言。样式
表单语言被指定为内容类型(例如,text / css)。
作者必须为此属性提供一个值;这个属性没有默认的
值。
This attribute specifies the style sheet language of the element's contents and overrides the default style sheet language. The style sheet language is specified as a content type (e.g., "text/css"). Authors must supply a value for this attribute; there is no default value for this attribute.
在旧版本的HTML(< = 4)似乎是尝试保持与导入样式表的< link>
方法的兼容性,其中需要类型
:
In old versions of HTML (<= 4) the type attribute appears to be an attempt to maintain compatibility with the <link>
method of importing stylesheets, where the type
is required:
<link rel="stylesheet" href="style.css" type="text/css" />
这篇关于除了text / css之外还有样式类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!