Hyperlinks, often referred to simply as 'links', connect various parts of a website, different files, or even other websites, providing a seamless navigation experience. In HTML, we create these essential navigational devices using the <a>
tag coupled with an href
attribute that specifies the destination of the link.
The example below establishes a simple link directed to https://www.codesignal.com
. Once you click "Click me!", you'll be redirected to the specified website.
Hyperlinks employ two strategies, absolute and relative paths, to connect pages and resources seamlessly. Absolute paths contain the full URL of the website:
Conversely, relative paths exclude the domain, a feature particularly convenient when linking within your own website:
In this example, about.html
is assumed to be in the same directory as the current page.
Sometimes, we might want the linked page to open in a new browser tab. This is where the target
attribute comes in. When set to , the attribute ensures the linked page opens in a new window or tab.
