Relative Links

So far, we have been linking to pages with similar links like this https://en.wikipedia.org/. Such links are called absolute links because they contain the complete link with all the details.

But there is another type of links, called relative links. A relative link looks like this: ./dog.html. The ./ means look in the current directory, and dog.html is the page we are linking to.

Relative links are used when we want to link to a page that is on our domain. That means if we wanted to link from the address startcoder.com/index.html to the address startcoder.com/about-us.html, we would use this relative link:

<a href="./about-us.html">About Us</a>

But if we wanted to link from the address startcoder.com to the address wikipedia.org, we would use an absolute link.

Instructions

In the file index.html, right below the opening body tag, create a link (element a) with the content: Dog that links to the address ./dog.html.

In the file index.html, right below the previously created link, create a link with the content: Cat that links to the address ./index.html.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

4/10

Relative Links | Start Coder