HTML Links

Hyperlinks, targets, email links and buttons as links.

✍️ 3 exercises + code challenge in this lesson

Links are created with the <a> (anchor) element. The href attribute holds the destination.

The target attribute

  • _self (default): opens in the same tab.
  • _blank: opens in a new tab.

Other kinds of links

  • Absolute URL: a full web address, e.g. https://codesintech.com.
  • Relative URL: a page on the same site, e.g. about.html.
  • Email: mailto:info@example.com.
  • Bookmark: #section-id jumps to an element with that id.

Key Takeaways: HTML Links

Mastering HTML Links helps you write clean and reliable HTML code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

HTML Links Code Example

HTML
<p><a href="https://codesintech.com" target="_blank">CodesInTech (new tab)</a></p>
<p><a href="mailto:info@codesintech.com">Send us an email</a></p>
<p><a href="#chapter2">Jump to Chapter 2</a></p>

<h2>Chapter 1</h2>
<p style="height: 300px;">Some long content...</p>
<h2 id="chapter2">Chapter 2</h2>
<p>You jumped here using a bookmark link.</p>
Free sign-in required · Google login available

HTML Links Practice Exercises

Check what you learned in “HTML Links”.

/ 3 solved
Fill in the blank

Make the link open in a new tab.

<a href="https://codesintech.com" ="">CodesInTech</a>
✓ Correct! Not quite. Try again.
Multiple choice

Which href creates an email link?

✓ Correct! Not quite. Try again.
Code challenge

Create a link with the text "Contact" that points to contact.html.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services