HTML Links

HTML links are elements, created by the <a> tag, that transport your users from one webpage to another or to a different part of the same page, with just a single click.

The Anchor Tag

In the land of HTML, there's a magical tool known as the anchor tag, or <a> tag. This tag can create a link to another part of your page or another website altogether. Here's how you write one:

<a href="http://www.example.com">Visit Example Website!</a>

In the example above, href is an attribute that tells the anchor tag where to navigate when clicked. The text "Visit Example Website!" is what your visitors will see, and what they'll click on to follow the link.

Understanding Relative vs. Absolute URLs

Your webpage can have two types of links or URLs to connect different pages - Relative and Absolute.

Absolute URLs point to another location on the internet. They include everything you need to find a page - the protocol (http: or https:), the domain (like www.example.com), and the specific path to a page or file (/adventures-of-huckleberry-finn.html).

Here's an example of an absolute URL in an anchor tag:

<a href="http://www.example.com/adventures-of-huckleberry-finn.html">Read The Adventures of Huckleberry Finn!</a>

Relative URLs are based on your current location and don't include the domain. Relative URLs are handy for linking to pages or files within the same website. Here's an example of a relative URL in an anchor tag:

<a href="/adventures-of-huckleberry-finn.html">Read The Adventures of Huckleberry Finn!</a>

The URL starts with a /, indicating that the link starts from the root directory, or the main folder that contains your website files.

There you have it! HTML Links: The 'Anchor' of Web Connectivity!

Previous Next

Written © 2024 Written Developer Tutorials and Posts.

𝕏