Beruflich Dokumente
Kultur Dokumente
A fundamental feature of HTML is that you can link documents. You can create link
from one page to another page inside location collection of documents or link to a
document anywhere on the internet. These links are called hyperlinks. You can create
hyperlinks by anchor tag (<a>). Images as well as text can be converted into a link. Now
let us demonstrate the anchor tag with code below :
<html>
<head>
<title>Hyperlinks</title>
</head>
<body>
<p>
Hi.....Check out this search engine known as <a
href="http://google.com">google</a>
</p>
</body>
</html>
You can format the link so that document opens in new browser. This can be done by
setting target attribute to “_blank”. Let us demonstrate it :
<html>
<head>
<title>Hyperlinks using target attribute</title>
</head>
<body>
<p>
Hi.....Check out this search engine known as <a href="http://google.com"
target="_blank">google</a>
</p>
</body>
</html>
You can change the color of the link by defining the following three attributes of the
<body> tag and setting their values to hexadecimal color values :
• link : It specifies the color of the links that has not been visited.
• vlink : It specifies the color of the links that has been visited.
<html>
<head>
<title>Hyperlinks</title>
</head>
<body link="#00FF66" vlink="#990567" alink="#0055FF">
<p>
Hi.....Check out this <a href="links1.html">document</a>
</p>
</body>
</html>
Somewhere probably you have clicked a link to send the email. By clicking the link, it
opens your email application. This type of link is created by setting href attribute to
mailto: protocol. Let us see how it is done :
<html>
<head>
<title>Hyperlinks - mailto</title>
</head>
<body>
<p>
Hey sourabh please mail me all your html tutorials <a
href="mailto:contact@sourabhandari.in">here</a>
</p>
</body>
</html>
You can also predefine the content of email's “Subject” line and message of the “body”
text as :
<html>
<head>
<title>Hyperlinks - mailto</title>
</head>
<body>
<p>
Hey sourabh please mail me all your html tutorials <a href="mailto:sourabh@tss-
Apart from linking documents and images, you can also define anchor tag to point to
specific location in your document. Let us see how it is done :
<html>
<head>
<title>Hyperlinks - Named anchors</title>
</head>
<body>
<a href="#location1">Location1</a><br />
<a href="#location2">Location2</a><br />
<a href="#location3">Location3</a><br />
<a href="#location4">Location4</a><br />
<p id="location1">
This is location1 of document
</p><br /><br /><br /><br /><br /><br /><br /><br /><br />
<p id="location2">
This is location2 of document
</p><br /><br /><br /><br /><br /><br /><br /><br /><br />
<p id="location3">
This is location3 of document
</p><br /><br /><br /><br /><br /><br /><br /><br /><br />
<p id="location4">
This is location4 of document
</p><br /><br /><br /><br /><br /><br /><br /><br /><br />
</body>
</html>
The following table describes the attributes that is supported by <a> tag :