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 Getting Started with HTML Lists and Links Challenge

Roop Gill
Roop Gill
420 Points

Unsure why I'm getting an error on my a tags

Not sure why I'm getting an error message with my code in this one. Thanks in advance for help!

index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lists and Links</title>
  </head>
  <body>
  <ul>
    <li><a href="http://cakes.html">Cakes</a></li>
      <li><a href="http://pies.html">Pies</a></li>
      <li><a href="http://candy.html">Candy</a></li>
    </ul>
  </body>
</html>

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Roop,

The instructions say the link will be like (example.html). In this format (and the .html), you are telling the HTML to link to another file in your project. When you added the http://example.html, the parser is thinking that you are trying to link to an external site (as indicated by the http://, and will throw an error because the .html states a file extension. I hope this explanation makes sense.

So, your syntax is 100% correct :thumbsup:, you just need to adjust the naming of the links. With files in your project directory (the file tree), you don't add any prefixes to the names... just the proper routing through the file tree. In this example, the other documents needing to be linked are in the root, just like the original HTML file holding the links. Don't worry if this file tree explanation doesn't make too much sense, you will learn much more on this in coming courses and is a bit beyond the scope of your original question. :)

So, once all fixed up, the HTML will look like this:

<!DOCTYPE html>
<html>
  <head>
    <title>Lists and Links</title>
  </head>
  <body>
  <ul>
    <li><a href="cakes.html">Cakes</a></li>
    <li><a href="pies.html">Pies</a></li>
    <li><a href="candy.html">Candy</a></li>
  </ul>
  </body>
</html>

Keep coding! :) :dizzy:

hey, Everything is ok just need to leave out the "http:// and just make it. <li><a href="cakes.html">Cakes</a></li> like this.

Roop Gill
Roop Gill
420 Points

Jason and Kevin - thanks so much for your answers. Silly me to trying to be too keen with the http:// and forgetting that I don't need to add that if the pages live in the same place.

Thanks a ton for writing back!