Link precedence in CSS2 class selectors

Submitted by Local Tree Child on Thu, 04/19/2007 - 08:04.

Had some problems with the precedence of an A tag class in my code. The link text keep coming up red instead of black as I had specified it should be in the dot-class in my style sheet, .MyClass. I tracked the problem down to the precedence for A.visited over <a href...class="MyClass">www.MyLink.com</a>.

Apparently the renderer gives more strength to A.visited, A.hoover etc. over just .MyClass for an <a href...class="MyClass">www.MyLink.com</a>. I don't know if it is inconsistent as MyClass is a user specified class especially put there. The thing that did the trick was to use A.MyClass which apparently wins over A.Visited for example.

Read more about Selectors in CSS2 at W3.org

urchinTracker(); // -->