Link precedence in CSS2 class selectors

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

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

urchinTracker(); // -->