Creating a Hyperlink
One of the major functionalities provided by HTML is to create links between Web pages. This implies that HTML helps you in navigating from one Web page to another by clicking the particular link in which the reference of the other Web page is stored.
Another functionality of HTML is to help you in adding images on a Web page. Let’s take an example, in which you are looking for a school catalog, which describes the features of the school. If the description of school in provided in text, the impact well not be influential. However, if the description includes some images of the school, such as the library, canteen, class rooms, and playground, the impact will be stronger. Therefore, to make your web page more attractive, HTML provides a facility to work with images.
You can also add multimedia objects on a Web page, which are the video and audio objects. The multimedia objects add impact to your web page; therefore, most websites include them in their Web pages.
A hyperlink is a link between Web pages and it is used to connect one Web page to another. When you click a link on a Web page, you are redirected (or sent) to the Web page specified as the destination Web page for the link. You can use the tags provided by HTML to create links, which provide a means to connect various Web pages or different sections of the same Web page.
In this section, you learn how to create a hyperlink, set the hyperlink color, and link different sections of the Web page.
Let’s first learn about creating a hyperlink.
You can create a hyperlink by using the anchor tag (<a>). The href attribute of the <a> tag takes the reference of the Web page. In order words, the href attribute specifies the destination of the link that you want to open in a browser. The term href stands for Hypertext Referecne.
Let’s do the following steps to create a hyperlink:
<!DOCTYPE html>
<head>
<title> Link </title>
</head>
<body>
<h2> To view page 1 click the hyperlink</h2>
<a href=”page1.html” target=”_target”>
<h1> Page 1 </h1>
</a>
</body>
</html>
Save the document with the name Hyperlink.html.
After creating a hyperlink you need to create a reference page for the hyperlink, that is, the Web page to which this hyperlink takes you on the click of it.
Let’s do the following steps to create a reference page:
<!DOCTYPE html>
<head>
<title> Page </title>
</head>
<body bgcolor=’aliceblue’>
<h1 align=”center”>Page 1</h1>
<h4 align=”center”>This is Page 1</h4>
</body>
</html>
Save the document with the name Page1.html.
Open the HTML document Hyperlink.html on browser and Click the hyperlink the Page1.html file opens in a new window.