Premium HTML Course

11. HTML Links

Links are one of the fundamental elements of the web, allowing users to navigate from one page to another. In HTML, links are created using the <a> (anchor) tag.

What Are HTML Links?

HTML Links, also known as hyperlinks, allow users to navigate between pages and external websites. The <a> tag is used to define a link. It requires the href attribute, which specifies the destination of the link.

Why Are HTML Links Important?

Creating HTML Links

To create a link, use the <a> tag with the href attribute. The href attribute specifies the URL or destination of the link.

Example 1: Basic Link


<a href="https://www.example.com">Visit Example.com</a>
        

Example 2: Linking to Another Page

To link to another page within your website, use a relative URL. Here's an example:


<a href="about.html">Learn More About Us</a>
        

Linking to an External Website

To link to an external website, use the full URL in the href attribute:


<a href="https://www.example.com">Visit Example.com</a>
        

Opening Links in a New Tab

To open a link in a new tab, add the target="_blank" attribute to the <a> tag:


<a href="https://www.example.com" target="_blank">Visit Example.com</a>
        

Linking to an Email Address

You can create a link to send an email by using the mailto: scheme:


<a href="mailto:example@example.com">Send Email</a>
        

Best Practices for Links

Conclusion

Links are essential for web navigation, both for users and search engines. They provide a way to connect different parts of your website and the wider web. In this lesson, we have learned how to create and style HTML links effectively.

In the next lesson, we will cover HTML Images and how to add visual content to your webpages.