HTML Links

Hyperlink elements establish clickable connections between documents, facilitating web navigation through anchor tags configured with href attributes and supplementary properties.

⏱️ 8 min read 📅 Last Updated: October 5, 2025

Quick Answer

How do you create links in HTML?

Create links using the <a> (anchor) tag with href attribute: <a href="URL">Link Text</a>. Add target="_blank" to open in new tabs, use relative paths for internal pages, and mailto: for email links. Links support images, buttons, and styled text for navigation and user interaction.

Hyperlinks enable seamless movement across pages, document sections, and external resources. Constructed via <a> (anchor) elements, these navigational components form the connective tissue enabling intuitive website exploration.

Complete Links Example

Here's a comprehensive example demonstrating various types of HTML links working together:

Complete Links Example

<!DOCTYPE html>
<html lang="en">
<head>
    <title>HTML Free Codes - Links Tutorial</title>
</head>
<body>
    <header>
        <h1>Welcome to HTML Free Codes</h1>
        <nav>
            <a href="#about">About</a>
            <a href="#tutorials">Tutorials</a>
            <a href="#contact">Contact</a>
        </nav>
    </header>

    <main>
        <section id="about">
            <h2>About Us</h2>
            <p>Learn web development at <a href="https://htmlfreecodes.com" target="_blank">htmlfreecodes.com</a>.</p>
        </section>

        <section id="tutorials">
            <h2>Our Tutorials</h2>
            <ul>
                <li><a href="https://htmlfreecodes.com/html">HTML Tutorial</a></li>
                <li><a href="https://htmlfreecodes.com/css">CSS Tutorial</a></li>
                <li><a href="https://htmlfreecodes.com/javascript">JavaScript Tutorial</a></li>
            </ul>
        </section>

        <section id="contact">
            <h2>Contact Us</h2>
            <p>Email: <a href="mailto:support@htmlfreecodes.com">support@htmlfreecodes.com</a></p>
            <p>Phone: <a href="tel:+1234567890">(123) 456-7890</a></p>
        </section>
    </main>

    <footer>
        <p><a href="#about">Back to top</a></p>
    </footer>
</body>
</html>

🎯 Link Best Practices

  • Use descriptive text: Avoid "click here" or "read more"
  • Open external links in new tabs: Use target="_blank"
  • Add security attributes: Use rel="noopener noreferrer" for external links
  • Provide clear hover states: Help users understand what's clickable
  • Use meaningful URLs: Make them readable and SEO-friendly
  • Test all links: Ensure they work correctly
  • Consider accessibility: Use proper contrast and focus indicators

Try it Yourself

Experiment with different types of HTML links and navigation!

Try Links Example

Test Your Knowledge