Skip to content
Learn Netverks

Lesson

Step 14/58 24% through track

links

Links and URLs

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~3 min
Level
beginner

This lesson

This lesson teaches Links and URLs—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of Links and URLs, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply Links and URLs in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When the previous lesson's MCQs feel easy and you can explain Links and URLs in your own words.

The anchor element <a> creates hyperlinks. The href attribute determines the destination; link text should describe the target without surrounding fluff.

URL shapes

  • Absolute: https://example.com/path—scheme + host + path.
  • Protocol-relative (legacy): //cdn.example.com/file.js—inherits scheme; avoid when possible.
  • Root-relative: /assets/logo.svg—starts at site origin.
  • Relative to document: ../images/photo.jpg—walks directories.
  • Fragment: #faq jumps within the page when matching id.

Non-HTTP schemes

  • mailto:user@example.com opens mail clients; include subject/body query params sparingly.
  • tel:+15551234567 triggers dialers on capable devices.
  • Custom schemes (slack://, app deep links) require installed handlers.

Security and UX attributes

  • target="_blank" should pair with rel="noopener" (and often noreferrer) for external windows.
  • download hints filename for same-origin or CORS-enabled downloads.
  • rel="nofollow sponsored" communicates crawling hints when required.
<a href="/css/intro">Continue to the CSS introduction</a>

Rendered output

Open the HTML reference desk (in-app link)

MDN: the <a> element ↗ External link uses target="_blank" + rel="noopener noreferrer".

Email support (mailto demo)

Accessibility

  • Write unique, descriptive link text (“Download Q3 report PDF”).
  • If multiple “Read more” links exist, ensure surrounding context differentiates them.
  • For icon-only links, provide visually hidden text or aria-label—but visible text is usually clearer.

Security and reality checks

  • target="_blank" + rel="noopener": mitigates window.opener attacks on cross-origin navigations.
  • Gifted URLs: user-supplied href invites javascript:/data: vectors—sanitize allowlists server-side.
  • Sponsored / tracking links: document rel usage with SEO/comms—implement consistently, not whimsically.

Accessibility test script (links)

  1. Tab path check: press Tab 3 times in the rendered output card and verify each link receives a visible focus style.
  2. Expected screen reader phrase: each link should be announced with meaningful text (for example, “Open the HTML reference desk, link”).
  3. 200% zoom check: zoom to 200% and ensure link text does not overlap or truncate so destination meaning stays clear.

Pitfalls juniors hit repeatedly

  • Using <a href="#"> as fake buttons—breaks semantics, hurts keyboard UX, pollutes history. Prefer button type="button" unless navigation truly occurs.
  • Links styled like buttons confuse expectations—anchors should navigate or jump; buttons trigger actions in-page.
  • Download attributes on cross-origin URLs may be ignored without proper CORS + Content-Disposition—never promise downloads you cannot honor.

<a> vs router frameworks

SPAs intercept clicks for client routing, but SSR + progressive enhancement paths still rely on sane hrefs for open-in-new-tab, copy link, prefetch, SEO, and no-JS fallbacks.

Important interview questions and answers

  1. Q: When should you use `strong` vs `b`?
    A: Use `strong` for semantic importance; use `b` only for stylistic offset without importance semantics.
  2. Q: Why is `target="_blank"` usually paired with `rel="noopener"`?
    A: It blocks the opened page from controlling the opener via `window.opener`, improving security.
  3. Q: Why avoid fake buttons built with ``?
    A: Anchors are for navigation; actions should use `

Challenge

Accessible link text

  1. Create two links: one descriptive, one vague (“click here”).
  2. Rewrite the vague link so it makes sense out of context.

Done when: both links work and the descriptive one needs no surrounding sentence to be understood.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump