HTML <style> tag

HTML <style> tag

The <style> tag is used to add CSS style rules to an HTML document.

An HTML document can contain multiple <style> tags.

The <style> tag can be used within the <head> tag or <body> tag. But it is a common practice to write within the <head> tag.

Example

HTML Online Editor
<!DOCTYPE html> <html> <head> <style> h1{ color:red; } h2{ color:blue; } p{ color:green; } </style> </head> <body> <h1>Fruit</h1> <p>I Like Banana</p> <h2>Car</h2> <p>I Like Jaguar</p> </body> </html>

Attributes

The following are the attributes of <style> tag. Also try Global attributes.

AttributeValueExplanation
mediamedia_querySpecifies which media/device the style should be applied to.
typetext/cssSpecifies the styling language as a MIME type.
This attribute is optional and defaults to text/css if it is missing.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author