How to add Link in Html
Here, we will describe how to link the text in two different following ways:
- Link the text another Html Page
- Link the text to the section on the same page.
Link the text to Another Page
If we want to add or insert the link in Html document for linking to another Html page with the current working page then we have to follow the steps which are given below. Using the following steps, we can easily link another Html page.
Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to add the link of another Html page.
Step 2: Now, move the cursor at the starting of that text which we want to create as a link. And then, type the anchor <a> tag at that point.
Step 3: Then, you have to close the anchor </a> tag at the end of that text which we want to create as a link as shown in the following block.
Step 4: Now, we have to add the attribute of anchor tag whose name is “href”. So, type the href attribute within the starting <a> tag. And, then we have to give the path of that html page which we want to add. So, type the path in the href attribute as described in the following block or Html code.
Step 5: And, at last, we have to save the Html code in the same directory or same location in which the linked Html page is saved and then run the code. The following screenshot shows the output of the above Html code:
Link the text to section on the same page
If we want to link a text to the particular part of the same page, follow the steps which are given below. Using the following steps, we can easily link another section in the same page.
Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to move on the specific section in the same Html page.
Step 2: Now, place the cursor at the starting of that section which we want to link. And, then we have to use the <a> anchor tag with the id attribute.
Step 3: Now, place the cursor at the starting of that text which we want to create as a link. And then, type the anchor <a> tag at that point.
Step 4: Then, you have to close the anchor </a> tag at the end of that text which we want to create as a link as shown in the following block.
Step 5: Now, we have to add the attribute of anchor tag whose name is “href”. So, type the href attribute within the starting </a> tag. And, then we have to give the id of that specific part of the same page. So, type the id followed by # sign in the href attribute. As described in the following block or Html code.
Step 6: And, at last, we have to save the Html file and then execute the file. The following screenshot shows the output of the above Html Code: