.demo1 div  + p {
    background-color: yellow;
}
 
    0
    
    span
    1
    
    2
    3
0
span1
2
3
.demo2 div  ~ p {
    background-color: yellow;
}
 
    0
    
    span
    1
    2
0
span1
2
.demo3 p[class=a] { background-color: yellow; }
.demo3 p[class~=b] { background-color: yellow; }
.demo3 p[class|=c] { background-color: yellow; }
 
    0
    1
    2
 
    3
    4
 
    5
 
    
0
1
2
3
4
5
.demo4 p:nth-child(2) { background-color: yellow; }
.demo4 p:nth-of-type(2) {background-color: red;}
 
    0
    1
    2
    
1
2
.demo5 p:active { background-color: yellow; }
 
    0
    
0
.demo6 p:focus { background-color: yellow; }
 
    0
0
.demo7 .p:first-line { background-color: yellow; }
.demo7 .p1:first-letter { background-color: yellow; }
 
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
ww
11111111111111111111111111
ww
我我
11
ww
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
ww
11111111111111111111111111
ww
我我
11
ww
.demo8 .p:nth-child(n+8):nth-child(-n+15) { background-color: yellow; }
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.demo9 .p:not(.p:first-of-type:nth-last-type(-n+10) ~ .p)  { background-color: yellow; }
.demo10 .p:not(.p:first-of-type:nth-last-type(-n+10) ~ .p)  { background-color: yellow; }
 
1
2
3
4
5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9