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

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

Shaimond Patterson
Shaimond Patterson
2,965 Points

Having trouble with the Forms, Divs, and inputs challenge in the Digital Literacy Course.

While attempting task 1 of the Forms, Divs, and Inputs challenge in the Treehouse Club - Mash of the Digital Literacy course. I get a bummer message that states my second <div> element needs to be set to "favorite_stuff" It's already set to that, so I'm not sure what I'm doing wrong or if this is a glitch in the system.

Please help.

Thanks

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

  <form>
    <div class="favorite_stuff">
    <div>

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

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

  </form>

</body>

2 Answers

Martin Ellis
Martin Ellis
6,724 Points

Hi Shaimond,

Looks like you have too many opening <div> tags in your code. Each div just needs 1 opening <div> tag and 1 closing </div>.

Your code should look like this...

<body>
  <h1>First Day of School</h1>

  <form>

    <div class="favorite_stuff">

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

    </div>

    <div class="favorite_stuff">

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

    </div>

  </form>

</body>
Shaimond Patterson
Shaimond Patterson
2,965 Points

Hello Martin, I realized my mistake now. Thanks for your help! This worked!

andren
andren
28,558 Points

When you load this challenge there are two div elements within the form element, those two elements that are already on the page are the ones you are meant to add the class "favorite_stuff" to. You are not meant to add new div elements with that class as you seem to have done, in addition it's worth nothing that you have not closed your new div elements with a closing tag (</div>) which means they are invalid elements as well.

If you remove the div elements you added and move the class attribute to the existing div elements like this:

<body>
  <h1>First Day of School</h1>

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

  </form>

</body>

Then you will be able to pass task 1.

Shaimond Patterson
Shaimond Patterson
2,965 Points

Hello Andren, Thanks for your help! I now realize what I was doing wrong and I finally passed the task!