HTML <style> (Style Information) Tag
Example
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
background: tomato;
}
h1 {
color: white;
}
p {
font-family: monospace;
}
</style>
</head>
<body>
<h1>The style element</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</body>
</html>
Meaning
The <style> element is used to add style sheet rules for a document. This element should be found only in the head element.
Style information also can be specified in external style sheets as defined by a <link> tag.
Style information can also be associated with a particular element using the styleattribute (inline styling).
Version: HTML 4, 4.01, 5
Standard Syntax
<style type="text/css">...</style>
Browser Support
Status
Attributes
Attribute | Value | Description |
---|---|---|
media | mediaQuery | Specifies what media/device the media resource is optimized for |
type | text/css | deprecated. Specifies the media type of the <style> tag |
Global Attributes
The <style> element also supports the Global Attributes in HTML.
Event Attributes
The <style> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
Most of the browsers will display the <style> element with the following by default value(s)
style {
display: none;
}