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

HTML5 <style> tag


May 03, 2021 HTML5


Table of contents


HTML5 is used to represent the style used by the document. Please refer to the following example:

Use the element in html documents:

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

<body>
<h1>这是一个标题</h1>
<p>这是一个段落。</p>
</body>

</html>
Try it out . . .

Browser support

HTML5 <style> tag HTML5 <style> tag HTML5 <style> tag HTML5 <style> tag HTML5 <style> tag

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.

Property Value Describe
media media_query Specify different media types for style sheets.
scoped scoped If you use this property, the style applies only to the parent element of the style element and its children.
type text/css Specifies the MIME type of style sheet.


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