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 How to Make a Website Creating HTML Content Create Navigation with Lists

Where does index.html take me when I visualize clicking <a href="index.html" ?

Hi,

I want to know why add the attribute "index.html" when making a link for Portfolio and not "portfolio.html" instead.

Thank you,

Gerardo Davila

index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Nick Pettit</title>
  </head>
  <body>
    <header>
      <a href="index.html">
        <h1>Nick Pettit</h1>
        <h2>Designer</h2>
      </a>
    </header>
    <section></section>
    <footer>
      <p>&copy; 2013 Nick Pettit.</p>
    </footer>
  </body>
</html>

1 Answer

Hi Gerardo, The "href" attribute in the <a> </a> tag requires a valid file path. However, the description/title could be different depending on the developer's choice. If I'm right, you are asking why the code was not written as:

   <a href="portfolio.html">
    <h1>Nick Pettit</h1>
    <h2>Designer</h2>
  </a> 

but rather:

   <a href="portfolio.html">
    <h1>Nick Pettit</h1>
    <h2>Designer</h2>
  </a> 

The reason is that the idea of the 'Portfolio' represents the content in the page rather than the filename of the html file. . In this case, the file is named 'index.html' but the content in it is relevant to that of a Portfolio - that's the reason why we used 'index.html' which represents the filename.

Also note that we did not create any file named 'portfolio.html' so if we had used that, it would have resulted in a dead link. However, depending on your choice, you can always rename the 'index.html' to 'portfolio.html' but just be conscious of which content you would want the 'href' to link to.

Hope this helps.

Thank you that answered my question

You are most definitely welcome Gerardo.