我可以跳过属性“类型”吗?在“风格”中HTML5中的标签? [英] Can I skip attribute "type" in "style" tag in HTML5?
问题描述
根据 W3Schools ,我可以跳过属性类型
标记脚本
在HTML5中。
According to W3Schools, I can skip attribute type
for tag script
in HTML5.
证据:
HTML 4.01和HTML5之间的差异
type属性在HTML 4中是
,但在HTML5中是可选的。
The "type" attribute is required in HTML 4, but optional in HTML5.
我可以用 style
标签? 我无法找到类似的说明。它只说
Can I do exactly the same with style
tag? I was unable to find similar note. It only says
type text / css 指定标签的媒体类型
但没有关于省略它的信息。我不关心IE,Edge或微软的那种废话。我想写尽可能少的不必要的代码。理想情况下,我只想使用:
but no info about omitting it. I don't care about IE, Edge or that sort of crap from Microsoft. I would like to write as less unnecessary code as possible. Ideally I would like to use just:
<style>.foo { color: red; }</style>
推荐答案
根据 文档 :
类型
此属性将样式语言定义为MIME类型(charset不应该是指定)。此属性为可选,
默认为text / css(如果缺少)。
This attribute defines the styling language as a MIME type (charset should not be specified). This attribute is optional and default to text/css if it's missing.
同时比较 html 4.01 和 html 5 :
html 4.01
type = content-type [CI]
此属性指定样式表
元素内容的语言并覆盖默认样式
表单语言。样式表语言被指定为内容
类型(例如,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 5
type属性提供样式语言。如果属性为
,则其值必须是指定样式
语言的有效MIME类型。不得指定charset参数。 type属性的默认
值(如果属性为
缺席时使用)为text / css。
The type attribute gives the styling language. If the attribute is present, its value must be a valid MIME type that designates a styling language. The charset parameter must not be specified. The default value for the type attribute, which is used if the attribute is absent, is "text/css".
这篇关于我可以跳过属性“类型”吗?在“风格”中HTML5中的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!