Skip to main content

<a> - Anchor

The anchor element is an element to create a link to another website on the Internet. It is also can be used to create a link to another element in the same website. The element can be defined by using a pair of <a> and </a> tag.

To use anchor element, you need to specify the location of the targeted element, which can be another website or an element in the same website), in a property named href in the opening tag of an anchor element. The location is usually a string representing a URL. For example:

<a href="https://github.com">GitHub</a>

The example above will make GitHub text to become a link to GitHub website, which located at https://github.com.

Possible Attributes

The following is the list of possible attributes in an anchor tag:

  • href: Contains the address, usually written as URI/URL value, to the targeted element.
  • target: How the browser will open the link. The possible values:
    • _self: Opens the link in the same window.
    • _blank: Opens the link in a new window.
    • _parent: Opens the link at the parent's page (only applicable when the anchor tag is defined as the value of a <iframe> tag).

Usage Example

Loading Code Editor...

Output: