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


This element includes the global attributes.


This attribute defines the styling language as a MIME type (charset should not be specified). This attribute is optional and defaults to text/css if it is missing.


This attribute defines which media the style should be applied to. Its value is a media query, which defaults to all if the attribute is missing.


A cryptographic nonce (number used once) to whitelist inline styles in a style-src Content-Security-Policy. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource’s policy is otherwise trivial.


This attribute specifies alternative style sheet sets.


This attribute specifies that the styles only apply to the elements of its parent(s) and children.

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.

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.



A simple stylesheet

<style type="text/css">
body {
  color: red;


Specification Status Comment
HTML Living Standard
The definition of 'style' in that specification.
Living Standard  
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.

Browser compatibility

The information shown below has been pulled from MDN's Github (https:/

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1 Yes133.51
type1 Yes133.51
media1 Yes133.51
title1 Yes133.51
scoped19 — 351 No21 No No No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support11 Yes461 Yes
type11 Yes461 Yes
media11 Yes461 Yes
title11 Yes461 Yes
scoped No No No21 No No No

1. 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.

See also