I have an anchor link, with a span within for styling reasons. I wish to change the background-color of the span on click, using the :active pseudo-class.

For some reason, :active would not work in IE8, but does for IE6 and 7. I see nothing wrong with my CSS and HTML, so what could possibly be wrong (other than IE8 itself, but let's not put that as an answer).

Simplified code below:

CSS:

.bigLink .innerText {
  background-color: #C00;
}
a.bigLink:active .innerText {
  background-color: #444;
}

HTML:

<a class="bigLink"><span class="innerText">Link text here</span></a>
  • Have you simplified the code too much so that you removed the href attribute on the anchor tag, or is it missing in your actualy code also? If it doesn't have a href attribute it's not a link and the pseudo classes for links doesn't apply. Guffa almost 7 years ago

2 answers

Dave V 5
0
points

We've had to uninstall IE8 inhouse because of many problems with older code. Our web site works fine with it but that's because it stays with the basics. Our in-house pages don't always work since it doesn't support older versions of .NET.

Answered almost 7 years ago by Dave V
0
points

The first declaration doesn't have a closing bracket first of all. You have the :active pseudo-class on the wrong element, try moving it to the .innerText and it works for me in IE8.

a.bigLink .innerText:active {
Answered almost 7 years ago by VagrantRadio