How to create links in HTML
To create a link in HTML, you use the anchor tag,
<a>
The href attribute is used to specify the web address (URL) of the page you want to link to.
Here is an example of how to create a link:
<a href="https://www.google.com">Visit Google</a>
This will display “Visit Google” as a hyperlink, and when clicked, the user will be taken to the Google homepage.
Opening links in a new tab:
You can open links in a new tab by using the target attribute. The value “_blank” will open the link in a new tab.
<a href="https://www.google.com" target="_blank">Visit Google</a>
This will open the Google homepage in a new tab when clicked.
Linking to a section within the same page:
If you want to link to a specific section within the same page, you can use the ID attribute to specify the section.
<a href="#section1">Jump to Section 1</a> ... <h2 id="section1">Section 1</h2>
This will create a link that, when clicked, will jump down to the section with the ID of “section1”.
Linking to an email address:
You can also use the anchor tag to create a link that will open a user’s email client with the recipient already filled in.
<a href="mailto:example@email.com">Send me an Email</a>
This will display “Send me an Email” as a hyperlink, and when clicked, the user’s email client will open with the recipient already filled in as “example@email.com”.
Linking an external resource with target blank:
<a href="https://www.bbc.com/" target="_blank">Visit BBC</a>
This link will open the BBC homepage in a new tab when clicked.
Written by: Maria Jensen 27-05-2023 Written in: HTML tutorials
I found this tutorial really helpful! I’ve been trying to figure out how to create links in HTML and this page explained it in a clear and concise manner . The step-by-step instructions, along with the code examples, made it so easy to understand. I appreciate that they also included some additional tips and best practices. I feel much more confident now in my ability to create links in my webpages. Thank you!
Wow, this tutorial on how to create links in HTML is exactly what I needed! I’ve been struggling to understand how to incorporate links into my website, but this guide broke it down in such a clear and concise way . The step-by-step instructions, along with the examples, made it super easy for me to follow along. I appreciate how beginner-friendly the content is, as it didn’t assume any prior knowledge. Thanks to this tutorial, I now feel confident in adding links to my HTML pages. Keep up the fantastic work!