CSS link property

Link style

  • Linked style, you can use any CSS attributes (such as color, font, background, etc.).
  • Four links states are:
    - A: Link - normal, unvisited link
    - a: visited - a link the user has visited
    when the user mouse over the link - hover: - A
    - A: the Active - the link is clicked Moment

The sample code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
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 */
</style>
</head>

<body>
<p><b><a href="https://blog.csdn.net/devin_xin/" target="_blank">这是一个链接</a></b></p>
<p><b>注意:</b> a:hover 必须在 a:link 和 a:visited 之后,需要严格按顺序才能看到效果。</p>
<p><b>注意:</b> a:active 必须在 a:hover 之后。</p>
</body>
</html>

note:

  • a: hover must follow a: link and a: visited later
  • a: active must follow a: hover behind

An example of application of the link

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<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;}

a.six:link,a.six:visited
{
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
width:150px;
text-align:left;
padding:4px;
text-decoration:none;
}
a.six:hover,a.six:active
{
background-color:#7A991A;
}
</style>
</head>

<body>
<p>将鼠标移至链接上改变样式.</p>

<p><b><a class="one" href="https://blog.csdn.net/devin_xin/" target="_blank">This link changes color</a></b></p>
<p><b><a class="two" href="https://blog.csdn.net/devin_xin/" target="_blank">This link changes font-size</a></b></p>
<p><b><a class="three" href="https://blog.csdn.net/devin_xin/" target="_blank">This link changes background-color</a></b></p>
<p><b><a class="four" href="https://blog.csdn.net/devin_xin/" target="_blank">This link changes font-family</a></b></p>
<p><b><a class="five" href="https://blog.csdn.net/devin_xin/" target="_blank">This link changes text-decoration</a></b></p>
<p><b><a class="six" href="https://blog.csdn.net/devin_xin/" target="_blank">This link with a block</a></b></p>
</body>

</html>
Published 32 original articles · won praise 25 · views 829

Guess you like

Origin blog.csdn.net/devin_xin/article/details/105031606