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>