Anchor Tag (<a>):
- The anchor tag (<a>) is used to create hyperlinks. It has an href attribute that specifies the destination of the link.
- target="_blank" is used to open the link in a new tab or window.
Absolute URL:
- Specifies the full path to a resource, including the protocol (http:// or https://), domain name, and the path to the resource.
- Example: <a href="https://www.example.com" target="_blank">Visit Example Website</a>
Relative URL:
- Specifies the path to a resource relative to the current document.
- Example: <a href="contact.html">Contact Us</a>
Email Link:
- Uses the mailto: scheme to open the user's default email client with a pre-filled recipient address.
- Example: <a href="mailto:info@example.com">Send an Email</a>
Anchor Link:
- Allows you to link to a specific section of the same document or another document by using an ID attribute.
- Example: <a href="#section2">Go to Section 2</a> links to <h2 id="section2">Section 2</h2>.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Hyperlink Examples</title>
</head>
<body>
<div class="container">
<h1>HTML Hyperlink Examples</h1>
<!-- Absolute URL -->
<h2>Absolute URL</h2>
<a href="https://www.example.com" target="_blank">Visit the Website</a>
<!-- Relative URL -->
<h2>Relative URL</h2>
<a href="contact.html">Contact Us</a>
<!-- Email Link -->
<h2>Email Link</h2>
<a href="mailto:info@example.com">Send an Email</a>
<!-- Anchor Link -->
<h2>Anchor Link</h2>
<a href="#section2">Go to Section 2</a>
<!-- Section 2 -->
<h2 id="section2">Section 2</h2>
<p>This is Section 2 of the document. An anchor link can
jump directly to this section.</p>
</div>
</body>
</html>
No comments:
Post a Comment