Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

style

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

The style global attribute contains CSS styling declarations to be applied to the element. Note that it is recommended for styles to be defined in a separate file or files. This attribute and the <style> element have mainly the purpose of allowing for quick styling, for example for testing purposes.

Usage note: This attribute must not be used to convey semantic information. Even if all styling is removed, a page should remain semantically correct. Typically it shouldn't be used to hide irrelevant information; this should be done using the hidden attribute.

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'style' in that specification.
Living Standard No change from latest snapshot, HTML5.1
HTML5.1
The definition of 'style' in that specification.
Working Draft Snapshot of WHATWG HTML Living Standard, no change from HTML5
HTML5
The definition of 'style' in that specification.
Recommendation Snapshot of WHATWG HTML Living Standard. From HTML 4.01 Specification, it is now a true global attribute.
HTML 4.01 Specification
The definition of 'style' in that specification.
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.

Browser compatibility

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)

See also

文档标签和贡献者

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