style

style 全局属性 包含应用到元素的 CSS 样式声明。要注意样式最好定义在单独的文件中。这个属性以及 <style> 元素的主要目的是快速装饰。例如用于测试目的。

用法注解:这个属性不能用于传递语义信息。即使所有样式都移除了,页面也应该保留正确语义。通常它不应用于隐藏不相关的信息;这应该使用 hidden 属性来实现。

规范

Specification Status Comment
WHATWG HTML Living Standard
style
Living Standard No change from latest snapshot, HTML 5.1
HTML 5.1
style
Recommendation Snapshot of WHATWG HTML Living Standard, no change from HTML5
HTML5
style
Recommendation Snapshot of WHATWG HTML Living Standard. From HTML 4.01 Specification, it is now a true global attribute.
HTML 4.01 Specification
style
Recommendation Supported on all elements but <base>, <basefont>, <head>, <html>, <meta>, <param>, <script>, <style>, and <title>.
CSS Style Attributes Recommendation Defines the content of the style attribute.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

另见

文档标签和贡献者

 此页面的贡献者: wizardforcel
 最后编辑者: wizardforcel,