Home > Web Front-end > Front-end Q&A > What types of css style sheets are there? What is selector priority?

What types of css style sheets are there? What is selector priority?

青灯夜游
Release: 2023-01-07 11:45:56
Original
4153 people have browsed it

There are three types of css style sheets: inline style sheets, internal style sheets and external style sheets. The selector priority is: "Universal selector>Element selector>Class selector>Attribute selector>Pseudo-class>ID selector>Inline style".

What types of css style sheets are there? What is selector priority?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

What are the types of css style sheets?

According to the position where the CSS style is written (or the way it is introduced), CSS style sheets can be divided into the following three categories:

1. Inline style sheets

Inline style is to put the CSS style directly in the tag within the line of code. It is usually placed in the style attribute of the tag. Since the inline style is directly inserted into the tag, it is the most direct way. method, and it is also the most inconvenient style to modify.

Example:

<p style="background-color: #999900">行内元素,控制段落-1</p>
Copy after login

2. Internal style sheet

The internal style sheet is contained in the