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

Syntax error with Anchor, apparent incorrect attribute? Code review

Shown above, I get an error stating that the Anchor tag isn't changed? I get the message "Bummer! You need to set the 'href' attribute of the second <a> element to 'pies.html'."

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

1 Answer

Shay Paustovsky
Shay Paustovsky
969 Points

Hi Matthew,

It's a very commom mistake when learning HTML, but don't get discouraged you're on the correct path. It's very common to confuse the <a></a> element with the <li></li> element.

The <a></a> element simply marks up text as a hyperlink, assuming you have an 'href=" " ' attribute. The <li></li> element marks up a single list item inside a list element <ul></ul> or <ol></ol>.

In your code example :

<ul>
  <a href="pies.html"><li>Pies</li></a>
</ul>

The problem is that the <a></a> element is not a descendant of the 'ol' or 'ul' elements. And it should look something like this :

<ul>
  <li><a href="pies.html">Pies</a></li>
</ul>

The <li></li> element "wraps" the <a></a> element as the text acts as a hyperlink.

Hopefully I've helped,

Shay

Thanks for your help Shay! That makes sense.