The <style>
contains style information for a document, or part of a document. By default, the style instructions written inside that element are expected to be CSS.
Content categories |
Metadata content, and if the scoped attribute is present: flow content. |
---|---|
Permitted content | Text content matching the type attribute, that is text/css . |
Tag omission | Neither tag is omissible. |
Permitted parents | Any element that accepts metadata content. |
Permitted ARIA roles | None |
DOM interface | HTMLStyleElement |
This element includes the global attributes.
type
text/css
if it is missing.media
all
if the attribute is missing.nonce
title
scoped
Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behaviour my change in the future.
Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
<style type="text/css"> body { color: red; } </style>
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'style' in that specification. | Living Standard | |
HTML5 The definition of 'style' in that specification. | Recommendation | No change from HTML 4.01 Specification. |
HTML 4.01 Specification The definition of 'style' in that specification. | Recommendation |
The information shown below has been pulled from MDN's Github (https:/github.com/mdn/browser-compat-data)
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 1 | Yes | 1 | 3 | 3.5 | 1 |
type |
1 | Yes | 1 | 3 | 3.5 | 1 |
media |
1 | Yes | 1 | 3 | 3.5 | 1 |
title |
1 | Yes | 1 | 3 | 3.5 | 1 |
scoped |
19 — 352 | No | 21 | No | No | No |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 1 | 1 | Yes | 4 | 91 | 6 | 1 |
type |
1 | 1 | Yes | 4 | 91 | 6 | 1 |
media |
1 | 1 | Yes | 4 | 91 | 6 | 1 |
title |
1 | 1 | Yes | 4 | 91 | 6 | 1 |
scoped |
No | No | No | 21 | No | No | No |
1. Mobile Internet Explorer (the previous branding of IE Phone - versions lower than 8) also has support.
2. From version 19 until version 35 (exclusive): this feature is behind the Enable <style scoped>
preference (needs to be set to true
). To change preferences in Chrome, visit chrome://flags.
<link>
element which allows for the use of style sheets.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style