Skip to content
html tutorial
Menu
  • About us
  • Disclaimer
  • Privacy Policy
Menu
href attribute of HTML anchor tag

HTML a tag- Anchor Tag

Posted on January 27, 2023

The <a> tag, also known as the anchor tag, is used to create a hyperlink to another web page or a specific location on the same page. The href attribute is used to specify the destination of the link.

Example:

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

This will create a link that, when clicked, takes the user to the website https://htmltutorial.xyz. The text “Visit Example” will be displayed on the page as the clickable link.

Example:

<p>Check out our <a href="https://htmltutorial.xyz/index.php/2023/01/17/html-heading-tags-importance-usage-seo-best-practices/">Heading Tag</a> for more information.</p>

<h2>Related Articles</h2>
<ul>
  <li><a href="#article1">Article 1</a></li>
  <li><a href="#article2">Article 2</a></li>
  <li><a href="#article3">Article 3</a></li>
</ul>

In the above example, first link will take user to another website’s blog page and second links will take user to specific sections within the same blog post.

Specify a location for Link using target attribute

The target attribute of the <a> tag can be used to specify where a link should open. The most common values for this attribute are:

_blank: This value will open the link in a new browser window or tab.

<a href="https://www.example.com" target="_blank">Visit Example</a>

_self: This value will open the link in the same window or tab. This is the default value if the target attribute is not specified.

<a href="https://www.example.com" target="_self">Visit Example</a>

_parent: This value will open the link in the parent frame.

<a href="https://www.example.com" target="_parent">Visit Example</a>

_top: This value will open the link in the full body of the window, breaking out of any frames.

<a href="https://www.example.com" target="_top">Visit Example</a>

name: This value will open the link in a named target frame.

<a href="https://www.example.com" target="frame_name">Visit Example</a>

It’s important to note that using target="_blank" will open the link in a new tab, but it also disables the “back” button on the browser, which can cause confusion for users. To avoid this, it’s better to use target="_self" or target="_top".

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • HTML Text Formatting

    HTML Text Formatting

    January 28, 2023
  • HTML Images Tag

    HTML Images Tag

    January 27, 2023
  • HTML Paragraphs: The building blocks of web content

    HTML Paragraphs: The building blocks of web content

    January 17, 2023
  • HTML Heading tags

    HTML Heading tags

    January 17, 2023
  • HTML Attributes

    HTML Attributes

    January 16, 2023
  • HTML Elements

    HTML Elements

    January 16, 2023
  • All HTML code editors and how to use it.

    All HTML code editors and how to use it.

    January 14, 2023
  • HTML Introduction (What is HTML?)

    HTML Introduction (What is HTML?)

    January 8, 2023
©2023 HTML TUTORIAL | Design: Newspaperly WordPress Theme