ysap
ysap

Reputation: 8115

How to set hyperlink color for an individual link?

I am writing a very simple HTML page for selecting among a few files. The linked-to files are the current an past versions of some data file.

I want the "current" link to be in blue and the "past" links to be in light-blue. This is easily achievable through setting of the font color property in the <A ..> tag.

However, doing so means the color of visited links is not changed to purple.

An alternative is to use link, vlink and alink properties in the <body ...> tag, as explained here.

But doing so means that all links look the same. Apparently, the link, vlink and alink properties do not work when put in the <A ...> tag context.

How can I set a different "visited link" color per link?

Upvotes: 0

Views: 279

Answers (1)

Justinas
Justinas

Reputation: 43451

You can use a:visited selector for that:

<html>
    <style>
        a.past:visited {
            color: light-blue;
        }

        a.current:visited {
            color: blue;
        }
     </style>
     <body>
         <a class="current" href="#">Link</a>
         <a class="past" href="#">Link</a>
     </body>
</html>

Upvotes: 1

Related Questions