Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to insert link in HTML

Before we dive into the specifics, let's take a quick moment to understand what HTML links are. In simple terms, HTML links, often called hyperlinks, are a way for users to navigate between web pages. Imagine them as portals which transport you from one location to another, like the mystical wardrobe that leads the Pevensie children to Narnia in C.S. Lewis's Chronicles of Narnia.

An HTML link is created using the <a> HTML tag. The 'a' in <a> stands for 'anchor'. Think of it like an anchor that holds a ship in place. Similarly, the <a> tag holds the link in place.

Now, let's see how a basic HTML link looks:

<a href="">Visit</a>

Here, the href attribute is the actual link. The text between the opening <a> tag and the closing </a> tag is what the users see and click on. In this case, "Visit" is the link text.

To insert a link in HTML, we use the <a> tag and the href attribute. The href stands for 'Hypertext REFerence' and its value is the URL (or website address) you want the link to direct to.

Here's an example:

<a href="">Google</a>

In this example, when you click on the text "Google", you will be taken to

Now, while "" clearly tells us where the link leads to, it's not very user-friendly. Imagine a page full of such URLs. It would be challenging to understand what each link leads to. To make links more user-friendly, we can change the link text to something more descriptive.

Consider this example:

<a href="">Visit Google</a>

Now, it's clear that clicking on this link will take you to Google. It's like providing a label to the portal; instead of just showing the portal's address, we're also telling where it leads to.

Sometimes, you may want the link to open in a new browser tab or window. This is especially useful when you don't want users to navigate away from your page. To achieve this, we use the target attribute with _blank as its value.

Here's how you can do it:

<a href="" target="_blank">Visit Google</a>

In this example, clicking on "Visit Google" will open Google in a new browser tab or window.

You can also add a title to your link. The title is displayed as a tooltip when you hover over the link. This can provide additional information about the link. To add a title, use the title attribute.

Here's an example:

<a href="" title="Click to visit Google">Visit Google</a>

In this case, hovering over "Visit Google" will display the tooltip "Click to visit Google".

Wrapping Up

Creating links in HTML is like creating portals for users to jump from one web page to another. By using the <a> tag along with the href, target, and title attributes, you can create informative and user-friendly links. Just like the carefully labelled portals in a fantasy world, these links guide your users in their journey across the vast expanse of the web. Happy coding!