As far as I understand, CSS-specific rules indicate that the pseudo-class has the same weight as the tag selector. Thus, a div pa selector will be more specific than a: link.
But, as the following test case shows, this does not seem to be the case. Why is the link red?
<!DOCTYPE HTML> <html> <head> <title></title> <meta charset="UTF-8"> <style type="text/css" media="screen"> a:link { color: red; } div pa { color: green; } div.foobar pa { color: green; } </style> </head> <body> <div> <p> <a href="http://somecrazyurlwierdthing.com">A link... why is it red?</a> </p> </div> <div class="foobar"> <p> <a href="http://somecrazyurlwierdthing.com">But it turns green when you add a class selector.</a> </p> </div> </body> </html>
An example of the inclusion of the "div.foobar pa" selector has been edited.
css css-selectors
timmfin
source share