html anchor tags | link in html | what is anchor tags
HTML Anchor Tags
HTML anchor tags, also known as hyperlink tags or <a>
tags, are used to create clickable links on a web page. They allow you to navigate to different sections within the same page or to other web pages.
Here's the basic syntax of an anchor tag
<a href="URL">Link text</a>
Let's break down the parts of the anchor tag:
<a>: This is the opening tag that indicates the start of the anchor tag.
href="URL": This attribute specifies the destination URL or the target location where the link should navigate to. It can be an absolute URL (e.g., "https://example.com") or a relative URL (e.g., "page.html").
Link text: This is the visible text that will be displayed on the webpage as the clickable link. It can be any text or even images.
Here are a few examples to illustrate the usage of anchor tags:
Linking to an external webpage:
<a href="https://example.com">Visit Example</a>
Linking to a specific section within the same page using an ID:
<a href="#section-id">Go to Section</a>
...
<section id="section-id">
<!-- Section content goes here -->
</se
ction>
Linking to a different page within the same website:
<a href="page.html">Go to Page</a>
Opening the link in a new browser tab or window using the target attribute:
<a href="https://example.com" target="_blank">Visit Example (opens in new tab)</a>
Comments
Post a Comment