Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Treehouse Club - MASH MASH - HTML Forms, Divs, and Inputs

Jan Lundeen
Jan Lundeen
5,781 Points

Get the error "Bummer! Your <div> elements need to both have 'class' attributes." What am I missing?

Hi,

When I added classes to both div sections on Challenge Task 1 of 2(First Day of School), I got the error "Bummer! Your <div> elements need to both have 'class' attributes."

I added classes to both sections (see code below). What am I missing?

<div> <div class="favorite_stuff"> <h4>Favorite Foods?</h4> <input name="food[]"> <input name="food[]"> <input name="food[]"> <input name="food[]"> </div> <div> <div class="favorite_stuff"> <h4>Favorite Animals?</h4> <input name="animal[]"> <input name="animal[]"> <input name="animal[]"> <input name="animal[]">

Thanks,

Jan

index.html
<body>
  <h1>First Day of School</h1>

  <form>

    <div>
      <div class="favorite_stuff">
      <h4>Favorite Foods?</h4>
      <input name="food[]">
      <input name="food[]">
      <input name="food[]">
      <input name="food[]">
    </div>

    <div>
      <div class="favorite_stuff">
      <h4>Favorite Animals?</h4>
      <input name="animal[]">
      <input name="animal[]">
      <input name="animal[]">
      <input name="animal[]">
    </div>

  </form>

</body>

2 Answers

Jan Lundeen
Jan Lundeen
5,781 Points

You're right. The open/close tags are unbalanced. I was thinking that the original <div > tag should be left alone, but it looks like that's not the case. I just need to add class = "favorite stuff" to the original tag. Thanks!

Jan

Steven Parker
Steven Parker
221,296 Points

It looks like you added a duplicate opening tag for the div elements.

Instead of adding the class to the existing div tags, you seem to have added a completely new opening div tag. So now the open/close tag pairs are unbalanced, plus the original div tags still do not have classes.