Anchor Tag in HTML
Last time we have seen, The Different Types of Lists in HTML. Now we are going to learn about Anchor Tag in HTML. So let's get started...
HTML Anchor Tag (<a>)
Each and every document in the world has a unique address including Web Documents too. The unique address is nothing but the Uniform Resource Locator (URL). Generally, the URL can be written in this form : "https://www.google.com".
HTML's Anchor markup element (<a>) is used to create hyperlinks that build the path between the source anchor and the destination anchor. The source anchor can include any content such as text, image, or button that links to the destination anchor.
There are anchor attributes to create functional hyperlinks. Those attributes are href and target, which will create a path to connect the Web pages.
Attributes of Anchor Tag
1. href Attribute :
The href attribute not only links the source and destination but also performs many useful operations. Some of the uses of the href attribute are as follows :
- This attribute is used to execute the script.
- It links to the resource using the protocol, this protocol can be HTTP or any other.
- This attribute helps us to link to any element on the webpage which has its own corresponding id.
Syntax :
<a href="HTML_Page.html" > HTML Page </a>
2. target Attribute :
Adding a "target" attribute and "_blank" attribute to the link will tell the visitor's (user's) browser to open the link in a new (blank) browser tab or window to render that code in the browser when a visitor clicks the link which will open in a new tab.
Syntax :
<a href="HTML_Page.html" target="_blank"> HTML Page </a>
Linking Webpages using Anchor Tag
Step 1 : Create a webpage with the name "First_Page.html" with the following code
<!DOCTYPE html>
<html>
<head>
<title> First Page </title>
</head>
<body>
<h1> My First Page </h1>
<p> Example of Linking webpage </p>
<a href="Second_Page.html" target="_blank"> Second Page </a>
</body>
</html>
Step 2 : Create a second webpage with the name "Second_Page.html" with the following code
<!DOCTYPE html>
<html>
<head>
<title> Second Page </title>
</head>
<body>
<h1>My Second Page</h1>
<p>Welcome to world of Hyperlinking..!!!</p>
</body>
</html>
Step 3 : Open the First web page(First_Page.html) in the browser and redirect to the Second web page by clicking on the first web page's "Hyperlink".
Output :
So, now it's time to end the session. See you guys Next Time, stay tuned for further updates on HTML Programming Languages...!!!
Our website will definitely help you to improve your Programming Skills and Knowledge.
Thanks for Visiting...!!!
0 Comments
Please do not add Any Spam link in Comments !