ravicepatel,
Show us a “working page” with the code that you are using that demonstrates the problem.
OR post a link to the test page on your web site. We must see the real code.
A “working page” starts with a <!doctype>
, includes the <head>
tags and whatever they contain including CSS, then the <body>
tags with examples of the links that are not colored correctly by the CSS, finally ends with </html>
. In other words, it is a minimal, properly coded, valid page that demonstrates the problem so we can see in our browser what you see in your browser.
You may also need to include screen shots or drawings that show what you wish to see… how you want the links to behave.
Additional information for us:
(1) Do you use the !important modifier very often when you write code?
(2) Do you know the meaning of the CSS cascade?
(3) Do you understand the concept of specificity?
(4) Do you know how to validate your HTML and CSS?
https://validator.w3.org/nu/ (HTML)
https://jigsaw.w3.org/css-validator/ (CSS) (same as @SamA74 posted).
Why is validation important? This exampe from your first post is invalid. There should be a space, not a semicolon, between “green” and “!important”. HOWEVER, !important should not really be used here at all because once a link has been visited, the hover, focus and active colors cannot override it. The coloring will no longer change on hover, focus, or active.
Demo.
Copy the following code to a file with an html suffix and open it in your browser.
The links in the following “working page” are dummys. Click them to see the coloring change.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>anchors</title>
<!--
https://www.sitepoint.com/community/t/html-link-disable-or-change-color-property-after-visiting-one-time/251722/
ravicepatel
Jan 29,2017 1:37 PM
-->
<style type="text/css">
p {
font-size:1.5em;
font-weight:bold;
}
a {
display:inline-block;
border:3px solid transparent;
border-radius:12px;
padding:3px 6px;
}
a:link {
color:blue;
}
a:visited {
color:purple;
}
a:hover,
a:focus {
border-color:blue;
}
a:active {
color:red;
border-color:red;
}
</style>
</head>
<body>
<p>To learn more about HTML and CSS, <a href="">go here and read.</a></p>
<p>To learn more about HTML and CSS, <a href="/">go here and read.</a></p>
<p>To learn more about HTML and CSS, <a href="#">go here and read.</a></p>
</body>
</html>