Sobes.tech
Intern

What is a hyperlink?

sobes.tech AI

Answer from AI

A hyperlink is an interactive element of a web page that, when clicked (or activated in another way), redirects the user to another resource (another page of the same site, a page of another site, a file, an anchor on the current page).

In HTML, a hyperlink is created using the <a> (anchor) tag. The main attribute is href, which specifies the URL of the resource.

<a href="https://www.example.com">Link text</a>

Attributes of the <a> tag:

  • href: Specifies the URL of the resource the link points to.
  • target: Determines where the linked document will open. Main values:
    • _self (default): Opens in the current window/tab.
    • _blank: Opens in a new window/tab.
    • _parent: Opens in the parent frame.
    • _top: Opens in the entire browser window, overriding all frames.
  • rel: Indicates the relationship of the current page to the target page. For example, nofollow, noopener, noreferrer.
  • download: Offers to save the linked resource instead of navigating to it.

A link can contain text, an image, or other HTML elements.

Example of a link to an anchor on the current page:

<a href="#section2">Go to the second section</a>

<!-- ... content ... -->

<h2 id="section2">Second section</h2>

Thus, hyperlinks are a fundamental mechanism for navigation on the internet and linking information.