Priority questions about selectors:
One of the most vivid things you can see in CSS is that he creates a priority score to measure the precedence of a selector:
Tag Selector, pseudo-class pseudo-element, priority integral is 0;
class Selector, attribute selector, priority integral is 10;
ID Selector, priority integral is 100;
The style attribute within the tag, priority integral is 1000;
Other selectors, such as wildcards and so on, have priority points of 0;
There is also a!important, his priority is positive infinity ...
Here are some differences between adjacent selectors and sub-selectors:
Look at the code first:
1 < body > 2 < p > againd </ p > 3 < strong > wants to is a good JavaScript developer. </ strong > 4 Body >
In cases where the sub-selector and the adjacent selector are only considered, there are two ways to select the <strong> tag:
1{2 //the style ... 3 }45{6//the style ... 7 }
At this point the two options are completely equivalent, and can not see what ...
Look at the bottom again!
1 <Body>2 <P>Againd</P>3 <Strong>Wants to is a good JavaScript developer.</Strong>4 <Strong>He also wants to be a good student!</Strong>5 </Body>
Look, now you want to use Body > strong{//...} If you select <strong>, both are selected, and P + strong {} is still only the first one, but if you think it's all, it's a big mistake!
... Here's another piece of code:
1 <Body>2 <P>Againd</P>3 <Strong>Loves</Strong>4 <Strong>Himself</Strong>5 <Strong>Adnby</Strong>6 <Strong>His mother</Strong>7 <Strong>His father</Strong>8 </Body>
For the above code, if you use P + strong to select <strong>, you will get the first <strong> tag, but you use strong + strong to make a selection, you will find that except for the first <strong> , the other four <strong> tags will be selected, and the four <strong> can be interpreted as a <strong> tag that is adjacent to the <strong> tag.
CSS Learning Note 1