SITE NAME

Adding Links

Hyperlinks are added to your site using the anchor <a> element.

Making Links

  1. Make a new anchor <a> element
  2. Place the text the user will see for the link inside the open and close tags.
  3. In the open tag, add a href attribute with the URL the user will be redirected to
Result:

href attribute

The href attribute is used to set the URL the user will be sent to when you click the link!

Absolute URL

When linking to external sites, the entire URL needs to be used.

Result:

Relative URLs

When linking to pages on your own site, you can use relative URLs!

These can be a little confusing, so first let's imagine how your site is structured as a file system.

Let's imagine your current page is at the URL https://yoursite.com/characters/princes/red.html

Your origin is https://yoursite.com/
Your directory is /characters/princes/
Your current file is /characters/princes/red.html

type href result
origin-relative url /stories https://yoursite.com/stories
same directory url ./blue.html https://yoursite.com/characters/blue.html
parent directory url ../ https://yoursite.com/characters/