HTML Link

HTML Link


HTML Links - Hyperlinks HTML links are hyperlinks. A hyperlink is a text or an image you can click on, and jump to another document. HTML Links - Syntax In HTML, links are defined with the <a> tag:



<a href="url">link text</a>

<!DOCTYPE html>
<html>
<body>

<p><a href="http://www.w3schools.com/html/">Visit our HTML tutorial</a></p>

</body>
</html>

Output:
Visit our HTML tutorial

Local Links The example above used an absolute URL (A full web address). A local link (link to the same web site) is specified with a relative URL (without http://www....).

<!DOCTYPE html>
<html>
<body>

<p><a href="html_images.asp">HTML Images</a> is a link to a page on this website.</p>

<p><a href="http://www.w3.org/">W3C</a> is a link to a website on the World Wide Web.</p>

</body>
</html>

Output:
HTML Images is a link to a page on this website.

W3C is a link to a website on the World Wide Web.

HTML Links - Colors When you move the mouse over a link, two things will normally happen: The mouse arrow will turn into a little hand The color of the link element will change By default, a link will appear like this (in all browsers): An unvisited link is underlined and blue A visited link is underlined and purple An active link is underlined and red You can change the default colors, by using styles:

<!DOCTYPE html>
<html>
<head>
<style>
a:link {
    color: green;
    background-color: transparent;
    text-decoration: none;
}
a:visited {
    color: pink;
    background-color: transparent;
    text-decoration: none;
}
a:hover {
    color: red;
    background-color: transparent;
    text-decoration: underline;
}
a:active {
    color: yellow;
    background-color: transparent;
    text-decoration: underline;
}
</style>
</head>
<body>

<p>You can change the default colors of links</p>

<a href="html_images.asp" target="_blank">HTML Images</a> 

</body>
</html>
Output:
You can change the default colors of links
HTML Images