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

index.html for id not required?

When in the article.html and in the nav, I did not need to type the index.html (../../index.html#about) but only the # (../../#about). Is this wrong?

Daniel Riches
Daniel Riches
19,847 Points

to get to the about section on the index.html page from the article.html page, you need to specify the page you want to go to and the section on that page. So this would be:

../../index.html#about

1 Answer

Jason Rich
seal-mask
.a{fill-rule:evenodd;}techdegree
Jason Rich
Front End Web Development Techdegree Student 10,048 Points

I'm wondering about this as well.

I paused the video and tried to create the sectional links on the About page on my own before seeing how Guil did it, just to try it. "../../#about" does work.

Maybe including "index.html" is more a best practice to make it more explicit for anybody reviewing the code?

EDIT:

I think the answer is in the next module about Root Relative Paths.

          <a href="../../index.html#about">About</a>

is the Document Relative Path.

          <a href="/#about">About</a>

is the Root Relative Path.

I think the browser ignores the "../../" as we put in our markup and only sees "/#about" and so works according to the Root Relative Path. Basically, "../../" may be redundant, unneeded code when using the Root Relative Path.