Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Stavros Sofroniadis
PLUS
Stavros Sofroniadis
Courses Plus Student 1,503 Points

About Relative & Absolute links

Dear Friends,

if we have a local website/remote server site and inside we have 2 folders:

1)stuff

 index.html

 history.html

2)things

 index.html

The above folders contains these files.

If we want to link index.html with history.html we will use relative link.

But if we like to link stuff/index.html with things/index.html what kind of link it is better to use absolute or relative?

Thank You,

1 Answer

Adam Pengh
Adam Pengh
29,881 Points

It's generally better to use relative links for internal links and absolute links for external links. So on your site, linking to the various files would look like:

<a href="/stuff/index.html">Stuff</a>
<a href="/stuff/history.html">History</a>

<a href="/things/index.html">Things</a>

For example, the first link says from the web server root directory, go to the directory "stuff" and get the file "index.html"

https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL