Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML <style> tags


May 05, 2021 HTML Reference Manual


Table of contents


HTML .lt;style> tags

The label contains detailed style details of the HTML document, and by default, style instructions written within that element are considered CSS.

Use the element in html documents:

<html>
<head>
<style type="text/css">
h1 {color:red;}
p {color:blue;}
</style>
</head>

<body>
<h1>A heading</h1>
<p>A paragraph.</p>
</body>
</html>

Try it out . . .

Browser support

HTML <style> tags HTML <style> tags HTML <style> tags HTML <style> tags HTML <style> tags

All major browsers support the hashtag.


Label definition and instructions for use

The label defines the style information for the HTML document.

In the element, you can specify how HTML documents are rendered in the browser.

Each HTML document can contain multiple labels.


Tips and comments

Tip: To link to an external style sheet, use the hashtag.

Tip: To learn more about style sheets, read our CSS tutorial.

Note: If the "scoped" property is not used, each label must be in the head head area.


The difference between HTML 4.01 and HTML5

The scoped property is a new property in HTML 5 that allows us to define styles for a specified part of a document, not the entire document.
If you use the scoped property, the specified style can only be applied to the parent element of the style element and its children.


Property

New : The new property in HTML5.

Attributes value describe
media media_query Specify different media types for the style sheet.
scoped New scoped If this property is used, the style is only applied to the parent element of the Style element and its sub-elements.
type text/css The MIME type of the style sheet is specified.


Global properties

The label supports the global properties of HTML.


The event property

The tag supports the event properties of HTML.


Related articles

HTML tutorial: HTML CSS

HTML DOM Reference Manual: Style Object