KodingKaro
HTML · Beginner · Links and Navigation

Navigation menus and safe new tabs

A navigation menu is a group of links for moving around a site, and the way external links open can affect both usability and security.

✓ What you will learn in this topic

  • Explain the purpose of Navigation menus and safe new tabs in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

Use nav for a major group of navigation links and label multiple nav regions so people can distinguish them. A link that opens a new tab with target=\"_blank\" should normally include rel=\"noopener\" so the new page cannot use the opener reference. Do not force every link into a new tab: users should know when a new context is expected.

Syntax

Group navigation anchors in nav. For intentional new tabs, use target=\"_blank\" and rel=\"noopener\".

Example 1: a small page

The accessible label identifies this navigation region to assistive technology.

<nav aria-label=\"Main\">
  <a href=\"/\">Home</a>
  <a href=\"/classes.html\">Classes</a>
</nav>

Expected result: A named navigation landmark contains two links in reading order.

Example 2: a practical page

The external link warns about the new tab in its text and prevents access to the opener window.

<nav aria-label=\"Account\">
  <a href=\"/profile.html\">Your profile</a>
  <a href=\"https://example.org/policies\" target=\"_blank\" rel=\"noopener\">Partner policies (opens in a new tab)</a>
</nav>

Expected result: The profile link opens normally; the partner policy link opens a separate tab safely.

Common mistakes

A link needs a valid href and descriptive text; opening a new tab should be a deliberate choice rather than a default.

Best practices

Make link purpose understandable from its text, use relative URLs for pages in the same site, and protect new-tab links with rel=\"noopener\".

Practice exercise

Create a small site navigation with links to two local pages, a full external URL, an email address, and a telephone number.

Lesson summary

  • Use nav for important link groups, label distinct navigation regions, and open new tabs selectively.
  • Make link purpose understandable from its text, use relative URLs for pages in the same site, and protect new-tab links with rel=\"noopener\".

Knowledge check

Which attribute pair communicates and protects an intentional new-tab link?

Show the explanation

target=\"_blank\" opens a new tab, and rel=\"noopener\" prevents the new page from controlling its opener.

Practical example

html
<nav aria-label=\"Main\">
  <a href=\"/\">Home</a>
  <a href=\"/classes.html\">Classes</a>
</nav>

Expected result:

A named navigation landmark contains two links in reading order.

Hands-on practice task

Create a small site navigation with links to two local pages, a full external URL, an email address, and a telephone number.

In this section

Other lessons in Links and Navigation

Broaden your knowledge

Related learning topics