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 HTML Basics Going Further with HTML Linking to Sections of a Web Page

As opposed to entering index.html before the ID, I simply just entered the #id after../../. Is this wrong?

As opposed to entering index.html before the #id, I simply just entered the #id after../../ and omitted the root folder entirely. It seemed to work fine. Is there a benefit to one or the other?

Example: <ul> <li><a href="../../index.html">Home</a></li> <li><a href="../../#about">About</a></li> <li><a href="../../#article">Articles</a></li> <li><a href="../../#contacts">Contacts</a></li> </ul>

2 Answers

Steven Parker
Steven Parker
231,275 Points

I would not expect that to work. Are you sure it does?

It would be interesting to take a look at a snapshot of your workspace. You could make one and post the link to it here.

https://w.trhou.se/hrqclplie2

Yeah, it's weird. When I I try to follow along with the next lesson regarding root-relative paths, 2 of those links stop working for some reason.

Steven Parker
Steven Parker
231,275 Points

I see what's happening now. ""../../#about"" is being handled the same as if it was ""../../index.html#about"" The root-relative version would be "/index.html#about"

For the ones that stopped working, just check the spelling. I noticed where "contact" and "contacts" were not being used consistently.

The advantage to root-based references is when the structure is certain to remain at one place on the server. Relative paths can be handy when entire sections might get moved to another location.