Easy Tutorial
❮ Tag Command Tag Abbr ❯

The <style> Tag in HTML

Example

Using the <style> element in an HTML document:


Browser Support

All major browsers support the <style> tag.


Definition and Usage

The <style> tag is used to define style information for an HTML document.

Within the <style> element, you can specify how the HTML document should be rendered in the browser.

Multiple <style> tags can be included in one HTML document.


Tips and Notes

Tip: To link to an external stylesheet, use the <link> tag.

Tip: For more information on stylesheets, refer to our CSS Tutorial.

Note: If the "scoped" attribute is not used, each <style> tag must be located in the head section.


Differences Between HTML 4.01 and HTML5

The "scoped" attribute is new in HTML5, allowing styles to be defined for a specific part of the document rather than the entire document.


Attributes

Attribute Value Description
media media_query Specifies the media type for the stylesheet.
scoped New scoped If used, the style applies only to the parent element and its children.
type text/css Specifies the MIME type of the stylesheet.

Global Attributes

The <style> tag supports HTML's global attributes.


Event Attributes

The <style> tag supports HTML's event attributes.


Related Articles

HTML Tutorial: HTML CSS

HTML DOM Reference: Style Object

❮ Tag Command Tag Abbr ❯