1

The :link pseudo selector styles elements before they are visited and :visited styles them after. Is there any difference between doing:

a { border-color: red; }

and

a:link {border-color: red} 

?

Ole
  • 41,793
  • 59
  • 191
  • 359

2 Answers2

2

Yes, Definitely difference is there. If your anchor tag does not contain any href values or only having # then the attribute a:link won't target the elements. Look at the snippet below, I am just using a and it targets all the elements.

a { color:green; }
<a href="#">link having #</a>
<a>link without href</a>
<a href="test.html">Link having some value</a>

Now i will try to use a:link, and if you look at that it will target only the element which has the href links.

a:link { color:green; }
<a href="#">link having #</a>
<a>link without href</a>
<a href="test.html">Link having some value</a>
Ole
  • 41,793
  • 59
  • 191
  • 359
Suresh Ponnukalai
  • 13,820
  • 5
  • 34
  • 54
  • OK - So IIUC a and a:link are essentially the same as long as the a element has an href attribute? – Ole Mar 22 '18 at 05:40
-2

a:link { color:red;}this make the link color red when it is not even used; a:visited {color :green } this makes the link look green even if it is visited once ..

Killer
  • 47
  • 3