Visited Link Colors

How to set a different color for visited and unvisited links in Html?
How to have link with no underlines using style sheet?

Explanation


Property :

a:visited
Many times we want our links to show different colors.
We might want our visited links to be shown in red color and font size as 10px.
We might want our non-visited links to be shown in green color and font size as 15px.
This can be achieved by using internal style sheet coding
For this, in the header portion add the style as

Usage:

<style>
a{color: green; font-size: 15px}
a:visited{color: red; font-size: 10px;}
</style>

Definition:

We can set the link property for visited links using the tag "a:visited".
We can set any property (text, box, font, background properties).

Example:


The below links will give you the result:
The first link is some dummy value so it will be treated as a non-visited link.
The second link is for the same page("link-styles.php") which is the visited link.

Result:


No underline Link:


Here we will show how to create links with out any underline
We use the attribute "text-decoration: none;" to handle it.

Example:

<style>
a{color: green; font-size: 15px}
a:visited{color: red; font-size: 10px;}
</style>
<a href="//www.hscripts.com" style="color: orange; font-size: 15px; text-decoration: none;">
Creating Link without a underline
</a>


Result:



Ask Questions

Ask Question