I've said the style rule before, and I know the style rule syntax is: selector + declaration block
such as: div{color:black;padding:10px;} The DIV represents the selector (here is the element selector), and the content in the curly braces is the declaration block.
Selector Selector used to specify which or which elements of a style rule can be used in an HTML document. There are several common selector types:
1. Element selector (type selector) : Any HTML element on the page that matches the selector, regardless of the position of those elements in the document tree.
such as: p{Background:aqua; color:pink;} Matches any P element on a Web page, regardless of the position of the P element in the document tree
2. Class selector: is used to select any HTML element that has a class attribute, in the form of syntax:. Class Name {property: value;}
The same class property value can appear multiple times on the same page
3.ID Selector:is used to select any HTML element that has an id attribute, in the form of syntax: #id名 {property: value;}
the same id attribute value can only appear once on the same page4. Wildcard selector: used to select all elements, Syntax :*{property: value}
5. Include selector : A descendant element that is used to select an element of a document
The first method:
The second method of
6. Pseudo-Class selector:four different states for formatting hyperlinks <a> elements in different ways
A: link{}selectors used in the not-visited linka:visited{} The selector used in the link that has been visited
a:hover{} A selector for the link on which the mouse cursor is placed, where hover can also be used in other elements to make edits to the style that the mouse cursor places on the target
a:active{} A selector on a link that gets focus (for example, clicked)
7. pseudo element Selector :(1): First-line The selector for the first row of an element
such as the first line of a paragraph
Only Hello is red.(2): First-letter The selector for the first character of an element
such as the first character of a paragraph
OnlyMoThe word is red.(3): First-child for <body> The first is a selector (: first-child) for all contents of the preceding element
suddenly look backIt's red.The color of no font content is red,because the first element in <body> is a div, not p
The priority of the selector: ID Selector > class selector > Pseudo class selector > element/pseudo element selector > wildcard Selector
CSS Base 2--Selector