HTML Links Get Certified
HTML Links and the href Attribute
HTML links are the foundation of web navigation, enabling you to connect pages, sections, and even email clients. By mastering hyperlink techniques and the href attribute, you can create intuitive and accessible hyperlinks that guide your visitors effortlessly.
Types of Links in HTML
- Internal Links: Link to another HTML page within the same website using relative paths.
- External Links: Open other websites using absolute URLs.
- Email Hyperlinks: Mailto links allow users to send emails directly from a webpage.
- Anchor Links: Jump to a specific section on the same page.
- Image Links: Wrap an image in an anchor tag to create clickable pictures.
- CSS Links: Link to external CSS files for styling.
- Link Decorations with CSS: Enhance hyperlinks with hover effects, color changes, and text-decoration.
HTML Link Examples
1. Internal Link to Another Page
Internal links connect one HTML page to another within the same website or folder. This improves navigation and allows users to move between related content seamlessly.
What this code does: Creates a simple internal link using a relative path.
<!-- Example: Link to another html page in same folder -->
<a href="/about-us">About Us</a>
2. External Link Open in New Tab
External links allow users to navigate from your site to different domains. By using target="_blank" and rel="noopener", these links open in a new tab securely and enhance the user experience.
What this code does: Opens an external website in a new tab with security attributes.
<!-- Example: External hyperlink with target -->
<a href="https://www.academicblock.com/" target="_blank" rel="noopener">Visit Academic Block</a> in a new tab.
3. HTML Email Link (mailto)
HTML email links use the mailto: protocol to open the user’s default email client with a pre-filled recipient address and optional subject line.
What this code does: Creates a mailto link that opens the user’s email client.
<!-- Example: Create mailto link -->
<a href="mailto:info@example.com?subject=Inquiry">
Send Us an Email
</a>
4. Anchor Link to Page Section
Anchor links use the href="#sectionID" attribute to jump directly to specific content within the same webpage, improving usability.
What this code does: Demonstrates an in-page anchor link that jumps to a section with a matching id.
<!-- Example: Anchor link -->
<a href="#section2">Go to Section 2</a>
<h2>Section 1</h2>
<p>Some content here...</p>
<br><br><br><br><br><br>
<hr>
<br><br><br><br><br><br>
<h2 id="section2">Section 2</h2>
<p>Some content here...</p>
5. Image Link Example
Image links wrap an <img> element in an anchor tag to turn pictures into clickable hyperlinks, enhancing both navigation and visual appeal.
What this code does: Makes an image clickable so users can navigate when they click the graphic.
<!-- Example: Image wrapped in a link -->
<a href="https://www.academicblock.net/test-image-gallery#4-birds">
<img src="https://www.academicblock.net/wp-content/uploads/2025/04/Bird-01-AB.jpg" alt="image of a bird">
</a>
<p>Click on the above Image</p>
6. Linking CSS with the HTML Link Tag
Linking CSS with the HTML <link> tag connects your HTML document to stylesheets, enabling centralized styling and better maintainability.
What this code does: Shows the correct way to link an external CSS file.
<!-- Example: Link to external CSS file -->
<link rel="stylesheet" href="css-file1/styles.css">
<p>This example shows how you can call an external CSS file in your webpage. Make sure you have set the right file path for styles.css.</p>
7. Link Decorations with CSS
Link decoration with CSS enables you to customize the appearance of anchor tags by modifying properties like color, text-decoration, and font-weight. Adding hover and visited state styles improves usability and creates engaging interactions.
What this code does: Styles a link with normal, hover, and visited states.
<!-- Example: Link decoration using CSS -->
<style>
a.decorated-link {
color: #0066cc;
text-decoration: none;
font-weight: bold;
}
a.decorated-link:hover {
color: #FFAE00;
text-decoration: underline;
}
a.decorated-link:visited {
color: #993399;
}
a.decorated-link:visited:hover {
color: #863b14;
text-decoration: underline;
}
</style>
<a href="https://www.academicblock.com" class="decorated-link">
Stylish Link Example
</a>
Additional HTML Links Resources and Best Practices
Understanding the proper use of links in HTML and the href attribute is crucial for optimizing user experience and SEO. Whether you are creating external links or setting up mailto links for email communication, these techniques will help you build an effective web navigation system.
Web Resources on HTML Links
1. Colorado State University: HTML Linking
2. California State University, Northridge: HTML Tutorial Links
3. University of Rochester: HTML Tutorial Links
4. Carnegie Mellon University: Writing HTML Links
5. University of Rhode Island: Adding Links to Your Document
6. MDN Web Docs: Creating Links
Questions and Answers related to HTML Links
HTML links are created using the <a> tag and the href attribute, which defines the destination URL. Example: <a href="https://example.com">Visit Example</a>. When clicked, it navigates to the specified page.
External links point to different websites: <a href="https://example.com">External Link</a>. Internal links connect pages within the same website: <a href="about.html">About Us</a>. Both use the href attribute.
To create a clickable hyperlink, use the <a> tag: <a href="https://example.com">Click Here</a>. This is the correct syntax to ensure users can navigate to the specified URL.
Use the mailto: scheme in the href attribute: <a href="mailto:example@example.com">Send Email</a>. This opens the default email client when clicked.
HTML supports internal, external, anchor, and email links. Internal links reference pages in the same site: <a href="page.html">Page</a>. External links go to other sites.
Use the target="_blank" attribute to open links in a new tab: <a href="https://example.com" target="_blank">Open in New Tab</a>.
To style a hyperlink, use CSS: a { color: blue; text-decoration: none; }. Link CSS to HTML using <link rel="stylesheet" href="styles.css"> in the <head> section.
The href attribute specifies the URL or action of a link. For email, use mailto: as the value: <a href="mailto:someone@example.com">Email Us</a>.
Use the mailto: scheme in the href: <a href="mailto:name@example.com">Contact Us</a>. You can include a subject using ?subject=Hello.
Use clear link text and valid URLs. Example: Internal link <a href="about.html">About</a>. External link <a href="https://example.com" target="_blank">External</a>. Keep navigation user-friendly.
🧪 Test Your HTML Code
Edit the HTML code on the left and click “Run Code” to see the result on the right.
Click “Run Code” to see the result here.