<style>

Did you know that you can read content offline by using one of these tools? If you would like to read offline MDN content in another format, let us know by commenting on Bug 665750.

Dash App

Summary

The HTML <style> element contains style information for a document, or a part of document. The specific style information is contained inside of this element, usually in the CSS.

Attributes

This element includes the global attributes.

type
This attribute defines the styling language as a MIME type (charset should not be specified). 'text/css' is assumed if this attribute is absent.
media
Which media should this style apply to. Should be a media query, see http://dev.w3.org/csswg/css3-mediaqueries.
scoped
If this attribute is present, then the style applies only to its parent element. If absent, the style applies to the whole document.
title
Specifies alternative style sheet sets.
disabled
If set, disables (does not apply) the style rules to the Document that are specified within the element.

Examples

A simple stylesheet

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

A scoped stylesheet

<article>
  <div>The scoped attribute allows for you to include style elements mid-document.
   Inside rules only apply to the parent element.</div>
  <p>This text should be black. If it is red your browser does not support the scoped attribute.</p>
  <section>
    <style scoped>
      p { color: red; }
    </style>
    <p>This should be red.</p>
  </section>
</article>

Live sample

Specifications

Specification Status Comment
WHATWG HTML Living Standard Living Standard No change from HTML5.
HTML5 Candidate Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support ? 21.0 (21.0) Not supported Not supported Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic suppport ? 21.0 (21.0) Not supported Not supported Not supported

See also

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

Tags (4)