Tuesday 14 January 2014

Link styles: example program

Links can be styled with any CSS property (e.g. color, font-family, background, etc.).
In addition, links can be styled differently depending on what state they are in.
The four links states are:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it

a:active - a link the moment it is clicked

a:link {color:#FF0000;}      /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#FF00FF;}  /* mouse over link */
a:active {color:#0000FF;}  /* selected link */

<!DOCTYPE html>
<html>
<head>
<style>
a.one:link {color:#ff0000;}
a.one:visited {color:#0000ff;}
a.one:hover {color:#ffcc00;}

a.two:link {color:#ff0000;}
a.two:visited {color:#0000ff;}
a.two:hover {font-size:150%;}

a.three:link {color:#ff0000;}
a.three:visited {color:#0000ff;}
a.three:hover {background:#66ff66;}

a.four:link {color:#ff0000;}
a.four:visited {color:#0000ff;}
a.four:hover {font-family:monospace;}

a.five:link {color:#ff0000;text-decoration:none;}
a.five:visited {color:#0000ff;text-decoration:none;}
a.five:hover {text-decoration:underline;}
</style>
</head>

<body>
<p>Mouse over the links to see them change layout.</p>

<p><b><a class="one" href="http://improvehtml.blogspot.in/" target="_blank">This link changes color</a></b></p>
<p><b><a class="two" href="http://improvejava.blogspot.in/" target="_blank">This link changes font-size</a></b></p>
<p><b><a class="three" href="http://rajpaintings.4t.com" target="_blank">This link changes background-color</a></b></p>
<p><b><a class="four" href="www.facebook.com" target="_blank">This link changes font-family</a></b></p>
<p><b><a class="five" href="www.google.co.in" target="_blank">This link changes text-decoration</a></b></p>
</body>



</html>



1. by default it looks red color a.one:link {color:#ff0000;(red)} is executed
2. if i place the mouse pointer on first link: it changes the color:  a.one:visited {color:#0000ff;}is executed

3. if i place the cursor on 3rd link , it changes the font size, that is a.two:hover {font-size:150%;} is executed

No comments:

Post a Comment