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
Build a primary navigation
easy15 minBuild 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
Link out to another site safely
easy15 minAdd 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
Add contact links
easy15 minAdd 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
Add a skip-to-content link
easy15 minAdd 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
Offer a file download
easy15 minAdd 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
Add a basic link
easy10 minLink the text "Docs" to https://example.com.
- 7
Link to another page
easy10 minLink "About" to /about.
- 8
Open a link in a new tab safely
easy10 minAdd target and the rel that prevents tab-nabbing.
- 9
Link to a page section
easy10 minLink "Jump" to the #details anchor.
- 10
Add a download link
medium10 minLink a file and mark it as a download.
Find the bug(10)
- 1
Fix the unsafe new-tab link
easy15 minThis 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
Fix the broken email link
easy15 minThis 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
Fix the mismatched anchor link
easy15 minThe "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
Fix the link with no destination
easy15 minThis "Terms of Service" link is missing its href entirely, so it isn't focusable or navigable. Give it href="/terms".
- 5
Fix the misspelled target
easy15 minThis 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
Fix the missing href
easy8 minWithout href the anchor is not a link at all.
- 7
Fix the unsafe new-tab link
easy8 mintarget="_blank" without rel exposes the opener.
- 8
Fix the wrong attribute
easy8 minLinks use href, not src.
- 9
Fix the missing hash on the anchor
easy8 minThe in-page link is missing its #.
- 10
Fix the link with no text
easy8 minThe 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