Search code examples
htmlcssanchor

Disable color change of anchor tag when visited


I have to disable the color change of an anchor tag when visited. I did this:

a:visited{ color: gray }

(The link is gray in color before visited.) But this is a way where I explicitly state the color after the link is visited, which is again a color change.

How can I disable the color change of an anchor tag when visited without doing any explicit color changes?


Solution

  • You can't. You can only style the visited state.

    For other people who find this, make sure that you have them in the right order:

    a {color:#FF0000;}         /* Unvisited link  */
    a:visited {color:#00FF00;} /* Visited link    */
    a:hover {color:#FF00FF;}   /* Mouse over link */
    a:active {color:#0000FF;}  /* Selected link   */