Home >Web Front-end >HTML Tutorial >Selector priority-:link pseudo-class_html/css_WEB-ITnose
Question: Please indicate the font color in the A tag in the following structure.
a{ color:#ccc}/* gray*/
.alink a{color:#F60}/* orange*/
h1 a{color:#F00}/* red*/
a:link{color:#009}/* blue*/
div h1 a{ color: #000}/* black*/
< ;/div>
Correct answer: blue
In fact, the verification method is very simple, you can know it after running it.
.alink a and a:link actually have the same priority. Whichever one is defined later will display the color of the one;
Determine the priority of the selector Levels can be thought of in terms of group fights: whoever has more people is stronger; there are the same number of people, and the one who comes after you will get the upper hand; even a small one is not as good as a big boss.
In other words, first count the number of selectors. Whichever style has more selectors will have a higher priority; if everyone has the same number of selectors, then the definition will take effect; if there are only There are many tag selectors, but they are not as good as a class or id selector.