Skip to main content

HTML Links — exercises and bug fixes

10 hands-on exercises and 10 find-the-bug challenges for the HTML Links lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.

Exercises(10)

  1. 1

    Build a primary navigation

    easy15 min

    Build a <nav> containing three links: Home linking to "/", About linking to "/about", and Contact linking to "/contact". Each link's text must match its destination.

    • Add a <nav> element.
    • Add three links inside the nav.
    • The first link should go to "/".
    • The second link should go to "/about".
  2. 2

    Link out to another site safely

    easy15 min

    Add a link with the text "MDN Web Docs" pointing to https://developer.mozilla.org that opens in a new tab. Because it opens in a new tab, protect the original page with rel="noopener noreferrer".

    • Link to https://developer.mozilla.org.
    • Open the link in a new tab with target="_blank".
    • Add rel="noopener noreferrer".
    • The link text should read "MDN Web Docs".
  3. 3

    Add contact links

    easy15 min

    Add an email link to hello@example.com and a phone link to +1-555-0100. Use the mailto: and tel: URL schemes.

    • Add a mailto: link.
    • The email link should go to hello@example.com.
    • Add a tel: link.
  4. 4

    Add a skip-to-content link

    easy15 min

    Add a "Skip to content" link before the header that jumps to the #main-content section, so keyboard users can bypass repeated navigation.

    • Add a link that reads "Skip to content".
    • The link should point to #main-content.
    • Keep the #main-content target in place.
  5. 5

    Offer a file download

    easy15 min

    Add a link to "/files/handbook.pdf" with the text "Download the handbook" that downloads the file instead of navigating to it, using the download attribute.

    • Link to /files/handbook.pdf.
    • Add the download attribute.
    • The link text should read "Download the handbook".
  6. 6

    Add a basic link

    easy10 min

    Link the text "Docs" to https://example.com.

  7. 7

    Link to another page

    easy10 min

    Link "About" to /about.

  8. 8

    Open a link in a new tab safely

    easy10 min

    Add target and the rel that prevents tab-nabbing.

  9. 9

    Link to a page section

    easy10 min

    Link "Jump" to the #details anchor.

  10. 10

    Add a download link

    medium10 min

    Link a file and mark it as a download.

Find the bug(10)

  1. 1

    Fix the unsafe new-tab link

    easy15 min

    This pricing link opens in a new tab but leaves the original page exposed to the new page via window.opener. Add rel="noopener noreferrer" to close the hole.

  2. 2

    Fix the broken email link

    easy15 min

    This link is supposed to open the visitor's email client addressed to support@example.com, but clicking it just navigates the current page. Fix the href.

  3. 3

    Fix the mismatched anchor link

    easy15 min

    The "Jump to FAQ" link should scroll to the FAQ section below, but its href doesn't match the section's id. Fix the href so it points at the real id.

    • The link should point to #faq.
    • Keep the #faq section in place.
  4. 4

    Fix the link with no destination

    easy15 min

    This "Terms of Service" link is missing its href entirely, so it isn't focusable or navigable. Give it href="/terms".

  5. 5

    Fix the misspelled target

    easy15 min

    This link should open the changelog in a new tab, but a typo in the target attribute makes it open in the current tab instead. Fix the target value.

  6. 6

    Fix the missing href

    easy8 min

    Without href the anchor is not a link at all.

  7. 7

    Fix the unsafe new-tab link

    easy8 min

    target="_blank" without rel exposes the opener.

  8. 8

    Fix the wrong attribute

    easy8 min

    Links use href, not src.

  9. 9

    Fix the missing hash on the anchor

    easy8 min

    The in-page link is missing its #.

  10. 10

    Fix the link with no text

    easy8 min

    The anchor is empty, so nothing is clickable.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace