0

I want my link only to change color after I click on it. I have added the appropriate a:link and a:visited pseudo-classes in the correct order. However, my link changes color when I refresh the page too and I don't want this.

2 Answers 2

1

I created a simple example for you

If you've never visited the link before, it will be black (default color)

If you've visited the link before, it will be blue

If you hover the link, it will be red

https://jsfiddle.net/ykrfqucw/1/

HTML: <a href="https://www.emrerothzerg.com">emrerothzerg.com</a>

CSS:

a{
  color: black;
}

a:visited {
  color: blue;
}

a:hover {
  color: red;
}

a:active {
  color: yellow;
} 

SASS (if you like to have):

a {
  color: black;
  &:visited {
    color: blue;
  }
  &:hover {
    color: red;
  }
  &:active {
    color: yellow;
  }
}
Sign up to request clarification or add additional context in comments.

Comments

1
#style  {
    background-color: red;
}

#style:focus {     
    background-color:yellow;    
}

#style:visited {     
    background-color:yellow;    
}

#style:active {     
    background-color:yellow;    
}

Several ways to do it below. Hope it helps

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.