06. Links <a>

Links are probably the most important element you can place on your webpage. They allow the user to traverse not only within your website, but also to external webpages.

The Anchor Tag

To define a link, we use the <a> tag with the "href" attribute.

The "href" attribute can either take an absolute URL, which is used to specify an external page, or it can be relative, meaning the webpage lives on the same server.

Absolute and Relative Paths

There are two types of links you should consider - the relative and absolute paths.

Absolute Paths

An absolute path name starts with a scheme (http://), and is able to independently direct the user to a webpage.

For example, the URL "http://www.youtube.com/channel/UCKPnCqn93Uwjg3frSHHrt9w" can direct the user by itself.

Relative Paths

A relative path name, on the other hand, directs the user to a link within the same website. If the link starts with a "/" then the user will be directed to the same webpage, with the corresponding link attached.

For example, if the user pressed a link that directed to "/home/about-us" from a page with the URL "www.johnsmith.com/home/contact", he/she will be directed to "www.johnsmith.com/home/about-us".

If the link has no "/" then the user is directed to a path within the same folder.

For example, if the user was on the same "www.johnsmith.com/contact" and pressed a link that directed him or her to "blog" then the user will be directed to "www.johnsmith.com/contact/blog".

Here, the first example is an absolute URL, while the second is relative.

<a href="https://www.youtube.com/channel/UCKPnCqn93Uwjg3frSHHrt9w">Visit our Youtube Channel!</a>
<a href="symbols">Adding Symbols to your HTML page</a>

Visit our Youtube Channel!

Adding Symbols to your HTML page

Build modern and responsive webpages

The Modern Web

Build modern and responsive webpages Try Front-end

The Modern Web will guide you through the most important tools of device-agnostic web development, including HTML5, CSS3, and JavaScript. The plain-english explanations and practical examples emphasize the techniques, principles, and practices that you'll need to easily transcend individual browser quirks and stay relevant as these technologies are updated.

$ Check price
34.9534.95Amazon 4.5 logo(30+ reviews)

More Front-end resources

Aching back from coding all day?

Inversion Therapy Table

Aching back from coding all day? Try Back Problems

Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.

$$ Check price
119.98119.98Amazon 4.5 logo(1,700+ reviews)

More Back Problems resources

Ad