HTML <style> tag

Updated: 10/11/2017 by Computer Hope

HTML style tagWhen writing in HTML, the <style> tag is used to change the appearance and position of various elements on a web page. It can be put into the <head> of the document and implemented as a class, or used for applying inline CSS to a single element. The following sections contain information about this tag, including an example of it in use, as well as 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

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <style> tag, as well as a description of each.

Usage note: 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 a media resource is designed to work with
scoped Designates that the styles only apply to this element's parent element
type Designates the media type of a <style> element

Compatibility

Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All versions All versions

Browser, Class, Compatibility, Inline, Web page, Web design terms