Navigating the Universe of Hyperlinks: A Beginners Guide to HTML Links
Understanding Hyperlinks: The Basics
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.
Connecting Pages and Resources: Using Hyperlinks
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.
Exploring the 'target' Attribute
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 _blank, the target attribute ensures the linked page opens in a new window or tab.
By clicking "Visit CodeSignal", you can keep the current page open while CodeSignal opens in a new tab.
Page Navigation: Using Element IDs for Internal Links
Long pages can significantly enhance their navigability by implementing internal links. HTML uses the id attribute to formulate these useful internal links and to uniquely identify an element on the page.
If you click "Go to Section 2", you'll be taken directly to the "Section 2" header.
Decoding the 'download' Attribute
