HTML Anchor Tag


Creating Links in HTML

The HTML anchor tag <a> is used to create links to other web pages, files, or sections within a page. The href attribute specifies the destination of the link. Here’s the basic syntax of the anchor tag:

<a href="destination-url">Link Text</a>

The href attribute specifies the destination of the link. The Link Text is the text that the user will see and click on to follow the link.

For example, let’s say we want to create a link to Google’s homepage. We would use the following code:

<a href="https://www.google.com/">Go to Google</a>

When the user clicks on the link, it will take them to the Google homepage.

You can also create links to sections within the same page by using the id attribute. For example, let’s say we have a section of a page with the ID “section1”. We can create a link to that section using the following code:

<a href="#section1">Go to Section 1</a>

When the user clicks on the link, it will take them to the section with the ID “section1”.

You can also add additional attributes to the anchor tag, such as target to specify where the link should be opened (_self, _blank, _parent, _top), or title to add a tooltip that appears when the user hovers over the link.

<a href="https://www.timesdarpan.com/" target="_blank" title="Visit Tiemsdarpan">Go to Times Darpan</a>

This will open the link in a new window or tab, and show a tooltip with the text “Visit Times Darpan” when the user hovers over the link.

In summary, the anchor tag <a> is a powerful tool for creating links in HTML. By using the href attribute, you can create links to other web pages or sections within a page. Additional attributes like target and title can be used to customize the behavior and appearance of the link.