How To Create Hyperlink in HTML?

HTML links, also known as hyperlinks, allow users to navigate between web pages or different sections of a web page by clicking on text or images.


Adding Link to a Text.

The most basic way to create a link in HTML is to use the <a> (anchor) element. The <a> element has an "href" (hypertext reference) attribute that specifies the URL or web address of the page or resource that the link should point to.

Example:

<a href="https://www.example.com">Visit example.com</a>
Output:


Adding Jump Link to a section of the Page.

You can also use the <a> element to create links to specific locations within a web page. To do this, you would use the "name" attribute and the "#" symbol, followed by the name of the location you want to link to. Then, you would create the location by using the "name" attribute on the element that you want to link to.

Example:
<a href="#section1">Go to section 1</a>
...
<h2 name="section1">Section 1</h2>

Adding Link to an Image.

You can also use the <img> element to link an image. In this case, the <img> element should be nested within the <a> element and the <img> element should have an "src" attribute that specifies the URL of the image file.

Example:
<a href="https://www.example.com">
    <img src="example.jpg" alt="Example">
</a>

It's important to note that the <a> element should always have a closing tag </a> and the value of the "href" attribute must always be enclosed in quotation marks.

⚡ Please share your valuable feedback and suggestion in the comment section below or you can send us an email on our offical email id ✉ algolesson@gmail.com. You can also support our work by buying a cup of coffee ☕ for us.

Similar Posts

No comments:

Post a Comment


CLOSE ADS
CLOSE ADS