Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials HTML HTML Links
HTML Beginner FREE

HTML Links

Lesson 1 of 16 Beginner Interactive

The <a> tag (anchor) creates a hyperlink to other pages, files, or locations.

Link Attributes

  • href — the URL to link to (required)
  • target — where to open the link:
    • _self — same window (default)
    • _blank — new tab/window
  • rel — relationship, e.g. noopener noreferrer

Syntax

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

<a href="url" target="_blank">Open in New Tab</a>
Types of Links
HTML
<!DOCTYPE html>
<html>
<body>
    <a href="https://www.sukhnexus.com" target="_blank">
        Visit SukhNexus
    </a><br>

    <a href="/about">About Us</a><br>

    <a href="mailto:info@sukhnexus.com">Email Us</a><br>

    <a href="https://www.sukhnexus.com" title="Go to SukhNexus">
        SukhNexus (hover for title)
    </a>
</body>
</html>

Practice

1
Exercise

Create a link that opens in a new tab.

Answer
<a href="https://example.com" target="_blank">New Tab Link</a>
2
Exercise

Create an anchor link that jumps to an element with id="footer".

Answer
<a href="#footer">Jump to Footer</a>

Quick Quiz

1

Which attribute opens a link in a new tab?

target="_blank" opens the link in a new tab or window.

Interview Questions

When using target="_blank", the new page can access the original page via window.opener. Adding rel="noopener" prevents this security vulnerability. rel="noreferrer" also hides the referrer information.