Careeroza
Links
HTML Links - Hyperlinks
Links let users click their way from page to page. A link is created with the <a> (anchor) element; href holds the destination.
<a href="url">link text</a>Absolute, Relative and Special Links
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p><a href="https://developer.mozilla.org/">Absolute URL (another website)</a></p>
<p><a href="/about.html">Relative URL (a page on this site)</a></p>
<p><a href="mailto:[email protected]">Send an email</a></p>
<p><a href="tel:+919876543210">Call us</a></p>
<p><a href="https://developer.mozilla.org/" target="_blank" rel="noopener">Open in a new tab</a></p>
</body>
</html>Result
The target Attribute
| Value | Opens the link in... |
|---|---|
_self | the same tab (default) |
_blank | a new tab or window |
_parent / _top | the parent frame / the full window |
Tip: Add rel="noopener" with target="_blank" so the new page cannot control the opening page.
Bookmarks
Example
Link to a part of the same page with an id and #:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p><a href="#chapter4">Jump to Chapter 4</a></p>
<h2>Chapter 1</h2><p>...</p>
<h2>Chapter 2</h2><p>...</p>
<h2>Chapter 3</h2><p>...</p>
<h2 id="chapter4">Chapter 4</h2><p>You jumped here!</p>
</body>
</html>Result
Exercise
Exercise: Create a link with the text "Careeroza" that opens https://careeroza.com in a new tab.
Show answer
<a href="https://careeroza.com" target="_blank" rel="noopener">Careeroza</a>