Home >Web Front-end >JS Tutorial >Priority and weight analysis of CSS selectors
This article mainly shares with you the priority and weight analysis of CSS selectors, hoping to help you learn more about CSS selectors.
Selector | Name | Instance | Description | Version |
---|---|---|---|---|
Universal selectors | *
| Match all elements2.1 | ||
Tag selectors (Type selectors) | p
| matches all
| 1||
Class selectors | .nav
| Matches all elements with class="nav"
| 1||
ID selectors | #wrapper
| match all## Elements with #id="wrapper"
1 |
||
Attribute selectors | a[data-url] |
Elements | # that match of all data-url attributes ##2.1
|
E[attr=val] |
a[data-url=' http'] |
Match all data-url="http" | elements with the attribute 2.1
|
E[attr~=val] | |
a[data-url~='http'] |
Matches all data-url | attributes containing http elements 2.1
|
E[attr^=val] | |
a[data-url^='http'] |
Matches all data-url | attributes starting with http elements 3
|
E[attr$=val] | |
a[data-url$='http' ] |
Matches all data-url | attributes ending with http elements 3
|
E[attr*=val] | |
a[data-url*='http '] |
Matches all data-url | attributes containing http
3
| E FDescendant selectors | |
p p | match all |
| elements under the element
1 ##E > F |
sub Selectors (Child selectors) |
Matches all children |
| 2.1
E + F
| Adjacent sibling selector||
Match all | The first element's sibling | Element
| 2.1
E ~ F
| Sibling selector|
Match all | elements with the same All | elements of level
| 3
##S1,S2,... selector Group |
label,input |
match all |
##:link | a:link | ||
---|---|---|---|
:visited |
a:visited | Matches visited links | |
:hover |
a:hover | Matches the element over which the mouse pointer is floating | |
:active |
a:active | Matches the element over which the mouse pointer is pressed | |
:focus |
input:focus | Matches the element that receives focus | |
The target pseudo-classes |
The target pseudo-class specifies the currently active anchor. You can use the target pseudo-class to set styles for the active anchor. |
Description
##:target | #tab1:target | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The language pseudo-classes Language pseudo-classes add styles to elements with the specified
The UI element status pseudo-class is mainly used to specify the status of elements in the form.
enabled/disabled Selector
whereInstanceDescription
InstanceDescription
|
The above is the detailed content of Priority and weight analysis of CSS selectors. For more information, please follow other related articles on the PHP Chinese website!