HTML <style> tag
The <style> tag is used to add style to the HTML document.
Syntax:
<style> CSS properties….</style>
Example
<style> body {background-color: lightskyblue;} h2 {color: darkslateblue;} p {color: crimson;} </style>
How Browser will display
INLINE.
Difference between HTML4.01, XHTML and HTML5
HTML4 | XHTML | HTML5 |
---|---|---|
None | None | None |
Attributes used with <style> tag
Attribute | Description |
---|---|
type | To inform about the type of media for the element. For this, you should text/css |
media | This sets the media or device for which this element is mostly suited for. You will use a media query for this purpose. |
Note/Warning/Info The <style> tag is only used for Internal and Inline CSS. For external CSS, you should use the Link Tag.
Global Attributes
The <style> tag supports Global attributes.
Event Attributes
The <style> tag supports Event attributes.
Supporting Browsers
Related Tags
<head> & <link> tags.