HTML Anchor tag

Categories - HTML Tags - HTML   Maniruzzaman Akash   1 month ago   151   2 minutes   0

HTML Anchor tag

The HTML Anchor tag <a> is used to create a hyperlink to another web page or a specific location within the same web page. It is one of the most commonly used HTML elements on the web.

The basic syntax for the <a> tag is:

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

The href attribute specifies the URL or location that the link should point to. The Link Text is the visible text that appears as a hyperlink on the web page.

For example, to create a hyperlink to the OpenAI website, the code would be:

<a href="">Visit Devsenv</a>

Live Preview:
Visit Devsenv

To create a link to a specific location within the same web page, you can use the id attribute to specify the target location and then use the # symbol followed by the id value in the href attribute of the <a> tag.

For example, to create a link to a section with an id of section-1, the code would be:

<a href="#section-1">Jump to Section 1</a>

Live Preview: Jump to Section 1

Then, in the HTML code for the section, you would include the id attribute like this:

<h2 id="section-1">Section 1</h2>
<p>This is the first section.</p>

When a user clicks on the hyperlink, the browser will automatically scroll to the location with the id of section-1.

HTML - Phrase Tags
HTML Images