HTML <style> tag

When writing in HTML (HyperText Markup Language), the <style> tag is used to change the appearance and position of various elements on a web page. It is placed in the document's <head> and implemented as a class, or used for applying inline CSS (Cascading Style Sheets) to a single element. The following sections contain information about this tag, including an example of it in use, and related attributes and browser compatibility.
Style tag with CSS
<style type="text/css"> <!-- p { color:orange; } --> </style>
Element with a style attribute example code
<p style="color:orange">This paragraph contains orange text!</p>
Example result
This paragraph contains orange text!
Attributes
All HTML tags support standard attributes that define the settings of an HTML element. Unlike other HTML tags, the <style> tag has no unique attributes.
The type attribute is optional in HTML5, but still required in HTML 4.
Attribute | Description |
---|---|
disabled | Designates that the <style> should not be applied to the current document. |
media | Designates what media/device for a media resource. |
scoped | Designates that the styles only apply to this element's parent element. |
type | Designates the media type of a <style> element. |
Compatibility
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | All versions | All versions | All versions | 5.0+ | All versions |
Browser, Class, Compatibility, Container tag, CSS, HTML, Inline, Tag, Web design terms, Web page