Master AI & Build your First Coding Portfolio with SkillReactor | Sign Up Now

Lesson 2 - HTML Tags And Elements

2.5 Links

Links in HTML are essential for navigating between webpages. The <a> tag is used to create a link. The href attribute specifies the destination URL.

Basic Link Example

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

In the example above, <a> creates a link labeled "Visit Example.com". Clicking on it will navigate to the webpage specified by the href attribute (https://www.example.com).

Opening Links in a New Tab

To open a link in a new tab, use the target="_blank" attribute:

<a href="https://www.example.com" target="_blank">Visit Example.com (opens in new tab)</a>

The target="_blank" attribute instructs the browser to open the linked webpage in a new tab or window.

By default, clicking on the link without the target attribute will navigate within the current tab or window.