Linking Documents
A link is specified using HTML tag <a>. This tag is called anchor tag and anything between the opening <a> tag and the closing </a> tag becomes part of the link and a user can click that part to reach to the linked document. Following is the simple syntax to use <a> tag.
<a href = "Document URL" ... attributes-list>Link Text</a>
Example :
Let's try following example which links https://akashtechviews.blogspot.com/ at your page −
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href = "https://https://akashtechviews.blogspot.com/ target = "_self">Tutorials Point</a>
</body>
</html>
This will produce the following result, where you can click on the link generated to reach to the home page of Tutorials Point.
The target Attribute
We have used target attribute in our previous example. This attribute is used to specify the location where linked document is opened. Following are the possible options −
Sr.No | Option & Description |
---|---|
1 | _blank Opens the linked document in a new window or tab. |
2 | _self Opens the linked document in the same frame. |
3 | _parent Opens the linked document in the parent frame. |
4 | _top Opens the linked document in the full body of the window. |
5 | targetframe Opens the linked document in a named targetframe. |
Example :
Try following example to understand basic difference in few options given for target attribute.
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href = "https://akashtechviews.blogspot.com//">
</head>
<body>
<p>Click any of the following links</p>
<a href = "/html/index.htm" target = "_blank">Opens in New</a> |
<a href = "/html/index.htm" target = "_self">Opens in Self</a> |
<a href = "/html/index.htm" target = "_parent">Opens in Parent</a> |
<a href = "/html/index.htm" target = "_top">Opens in Body</a>
</body>
</html>
This will produce the following result, where you can click on different links to understand the difference between various options given for target attribute.
Click any of the following links
Opens in New | Opens in Self | Opens in Parent | Opens in Body
HTML Anchor
The HTML anchor tag defines a hyperlink that links one page to another page. It can create hyperlink to other web page as well as files, location, or any URL. The "href" attribute is the most important attribute of the HTML a tag. and which links to destination page or URL.
href attribute of HTML anchor tag :
The href attribute is used to define the address of the file to be linked. In other words, it points out the destination page.
The syntax of HTML anchor tag is given below.
<a href = "..........."> Link Text </a>
Specify a location for Link using target attribute :
If we want to open that link to another page then we can use target attribute of <a> tag. With the help of this link will be open in next page.
Example:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p>Click on <a href="https://akashtechviews.blogspot.com/" target="_blank"> this-link </a>to go on home page of akashtecht.</p>
</body>
</html>
Output :
Appearance of HTML anchor tag
An unvisited link is displayed underlined and blue.
A visited link displayed underlined and purple.
An active link is underlined and red.
0 comments:
Post a Comment