HTML Links

Learn how to create links in HTML

Links are an essential part of HTML. They allow users to navigate between web pages. Here's how to create links in HTML:

To create a basic link, use the <a> tag with the href attribute:

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

Target Attribute

The target attribute specifies where to open the linked document:

<a href="https://www.example.com" target="_blank">Open in new tab</a>

To link to a section within the same page, use the id of the element as the href value:

<a href="#section-id">Go to Section</a>

To create a link that opens the user's email program, use mailto: in the href:

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

You can style links to look like buttons using CSS:

<a href="https://www.example.com" class="btn btn-primary">Click Me</a>

You can create a button link without CSS using the <button> element inside an <a> tag:

<a href="https://www.example.com"><button>Click Me</button></a>

Remember to always provide clear and descriptive text for your links to improve accessibility and user experience.