我可以跳过属性&“类型&"以& quot; style& quot;在HTML5中标记? [英] Can I skip attribute "type" in "style" tag in HTML5?

查看:60
本文介绍了我可以跳过属性&“类型&"以& quot; style& quot;在HTML5中标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 W3Schools ,我可以跳过属性 type 标记HTML5中的 script 标签.

According to W3Schools, I can skip attribute type for tag script in HTML5.

证据:

HTML 4.01和HTML5之间的区别

类型"属性为在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或Microsoft的那种垃圾.我想写尽可能少的不必要的代码.理想情况下,我只想使用:

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类型(不应指定字符集).此属性为可选,并且如果缺少,则默认为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

类型=内容类型[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 4.01-样式元素w3c

html 5

type属性提供样式语言.如果属性是当前,其值必须是可指定样式的有效MIME类型语.不能指定charset参数.默认值类型属性的值,如果属性为缺席的是"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".

html 5-样式元素w3c

这篇关于我可以跳过属性&amp;“类型&amp;"以&amp; quot; style&amp; quot;在HTML5中标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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