<style>

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 default to text/css if it's missing.
media
This attribute defines which media the style should apply to. Its value is a media query, which default to all if 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

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 (Yes) 1.0 (1.7 or earlier) 3.0 3.5 1.0
scoped No support[1] No support No support[2] No support No support No support
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 (Yes) 1.0 (1.0) 9.0[3] 6.0 1.0
scoped No support No support No support[2] No support No support No support

[1] Chrome 19 up to 34 supports it after activating the ‘Enable <style scoped>’ entry in chrome://flags. Removed in Chrome 35 and later.

[2] Firefox 21 implemented <style scoped>, but it was hidden behind a pref (layout.css.scoped-style.enabled) in content documents in Firefox 55+, as no other browsers support it.

[3] Mobile Internet Explorer (the previous branding of IE Phone — versions lower than 8) also had support for <style scoped>.

See also

  • The <link> element allowing to use external style sheets.