0

I was trying styles with a:visited, a:link, etc... and I found these 2 issues with a:visited:

  • why is font-size of a:visited ignored and a:link used instead

  • why is background-color not showing depending on whether a:link has background-color property or not

Example

a:link {
  /*background-color:#ff8000;*/
  font-size: 28px;
}

a:visited {
  font-size: 12px;
  background-color: grey;
  color: #10aaf0;
}

I googled a bit and read in w3schools that most of the styles are inherited from a:link for security/privacy issues, but what I don't understand is why background-color only works when I explicitly set it in a:link and then modify it in a:visited.

TL;DR:

  • What's the difference between explicitly set background-color for a:link to let a:visited apply its own background-style?
  • Is it still sensitive to those browser history query attacks through CSS?

It seems to behave the same way in the browrsers I tried: Chrome 45 and in IE 11.

40detectives
  • 350
  • 1
  • 3
  • 12

1 Answers1

0

I can't speak of security issues since I haven't heard of such thing associated with anchor tags. But a:link selector in most of the cases acts like a since it's applied to anchor tags with href attribute. And a:visited only applies to links which user has visited before. Other than that you should be aware of the order of declaring your styles.

For example take a look at this: http://codepen.io/anon/pen/ojzwgY

It works as expected in Firefox, Safari and Chrome

Nojan A.
  • 881
  • 1
  • 11
  • 27