HTML5 <style> visited color not working consistently

Joined
Sep 4, 2015
Messages
8
Reaction score
0
Points
1
I am very sure that the code I have written is correct and it sometimes works, but it sometimes does not work. The visited color (green or #00FF00) comes up after visiting a site but not always. What could cause this?

Code:
<style>

body {
  background-image: url(<link removed>);>
  background-repeat: no-repeat;
}

a:link {
  color: #0000FF;
  background-color: transparent;
  text-decoration: none;
}

a:visited {
  color: green;
  background-color: transparent;
  text-decoration: none;
}

a:hover {
  color: #000000;
  background-color: transparent;
  text-decoration: underline;
}

a:active {
  color: #FFFF00;
  background-color: transparent;
  text-decoration: underline;
}

</style>

Thank you for your help.

James Adrian
 

Riddhima

New member
Joined
May 1, 2023
Messages
1
Reaction score
0
Points
1
The code you provided seems to be fine, so the problem might be related to the browser cache. When you visit a website, your browser stores certain information, including the page content, images, and styles. This information is used to load the page faster when you visit it again.
If the visited color (green or #00FF00) is not appearing consistently, it could be because the browser is loading a cached version of the page instead of the updated version that includes the visited link style. To fix this issue, you can try clearing the browser cache and reloading the page.

Alternatively, you can add a random string to the CSS file link in the HTML file. This forces the browser to load the updated CSS file instead of a cached version. For example, you can modify the CSS file link to look like this:

Code:
<link rel="stylesheet" href="style.css?v=1">

By changing the value of the "v" parameter, you can ensure that the browser loads the updated CSS file even if it has cached an older version.
 

DKenn

New member
Joined
Aug 5, 2023
Messages
1
Reaction score
0
Points
1
Yes, your code looks fine, however the problem might lay in the HTML or somewhere else your styles.

Also, if you are using a CMS like WordPress, try disabling caching plugins to see if the problem persists.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top