Skip to main content

Command Palette

Search for a command to run...

Anchor Tag in HTML

Published
•2 min read•View as Markdown
Anchor Tag in HTML

Anchor Tag

An anchor tag is a HTML element that creates a link to a target URL. When correctly implemented, the link can wrap around text, images, or as buttons, so that users can interact with it and visit the link's destination.

Example in HTML

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

Link Attributes

  • href : Href stands for hypertext reference. This attribute defines the target address of the document, which this time is linked to (https://www.google.com)

Example

<a href="google.com"></a>

  • name : The name attribute of the anchor tag can be used to enable users to “jump” to a specific point on a page (jump marker, anchor). This is especially useful with large pages or subdivisions.

Example

<a name="to top"></a> or
<a name="#Content">Content</a>

  • target : The target attribute specifies how the destination page or the target document should be opened. “target=” _ blank “ is used for the opening of the target page in a new tab. This is the usual option when using target attributes for linking to other pages.

Example

<a href="http://www.mypage.com" target="_blank">Linktext</a>

The target attributes contains different types of values for different purposes. For example,

  • target="_blank" : The linked page opens in the new window.
  • target="_self" : The associated document is opened in the same window.
  • target="_parent" : The associated document is opened in the immediate parent of the current window.
  • target="_top" : The associated document is opened in the full original window cancelling all other elements.

That's all from my side. Thanks a lot for reading my article.