The HTML <style> element 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 |
Attributes
This element includes the global attributes.
type- This attribute defines the styling language as a MIME type (charset should not be specified). This attribute is optional and defaults to
text/cssif it's missing. media- This attribute defines which media the style should apply to. Its value is a media query, which defaults to
allif the attribute is missing. title- Specifies alternative style sheet sets.
scoped- Specifies that the styles only apply to this element's parent element and that element's child elements.
Examples
A simple stylesheet
<style type="text/css">
body {
color:red;
}
</style>
Specifications
| 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 |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic Support | 1.0 | (Yes) | 1.0 | 3.0 | 3.5 | 1.0 |
type | 1.0 | (Yes) | 1.0 | 3.0 | 3.5 | 1.0 |
media | 1.0 | (Yes) | 1.0 | 3.0 | 3.5 | 1.0 |
title | 1.0 | (Yes) | 1.0 | 3.0 | 3.5 | 1.0 |
scoped | 19.0 — 35.02 | No | 21.0 | No | No | No |
| Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
| Basic Support | 1.0 | 1.0 | (Yes) | 1.0 | 9.01 | 6.0 | 1.0 |
type | 1.0 | 1.0 | (Yes) | 1.0 | 9.01 | 6.0 | 1.0 |
media | 1.0 | 1.0 | (Yes) | 1.0 | 9.01 | 6.0 | 1.0 |
title | 1.0 | 1.0 | (Yes) | 1.0 | 9.01 | 6.0 | 1.0 |
scoped | No | No | No | 21.0 | No | No | No |
1. Mobile Internet Explorer (the previous branding of IE Phone - versions lower than 8) also has support.
2. From version 19.0 until version 35.0 (exclusive): this feature is behind the Enable <style scoped> preference (needs to be set to true). To change preferences in Chrome, visit chrome://flags.
See also
- The
<link>element allowing to use external style sheets.

