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

mustafa
mustafa
1,566 Points

Treehouse MASH - div elements

Hi, I've been having trouble making progress beyond a div-element challenge in the Treehouse Club MASH track. Can someone please help me understand my error in the following code:

<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>

4 Answers

Tanja Schmidt
Tanja Schmidt
11,798 Points

Hi, you've doubled your opening <div>-tag. You don't need to add another tag to include the class, the tag itself works fine no matter how many classes or ids or other attributes you include. So just delete the empty opening <div>-tag on each div and you'll do fine.

      <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>
mustafa
mustafa
1,566 Points

That worked great. Thanks so much for your help, really appreciate it:)

Anusha Singh
PLUS
Anusha Singh
Courses Plus Student 22,106 Points

Hi, you have actually doubled the div element

You typed:

   <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>

but the correct one is:

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

  <form>

    <div>

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

    <div>

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

  </form>

</body>

Please remove the <div class="favorite_stuff"> from the starting div element.

If you want to add a class to the dive element please do this:

  <div class="favourite_stuff">
 </div>
mustafa
mustafa
1,566 Points

Thanks a lot, appreciate it.

mustafa
mustafa
1,566 Points

I noticed in your profile that you registered in April this year. Were you starting from scratch? Your progress is really impressive:)

Tanja Schmidt
Tanja Schmidt
11,798 Points

Thanks a lot! Yes, I basically started from scratch. I tried learning online only with free resources a few weeks beforehand but it didn't work for me. I simply didn't understand the most basic fundamentals and couldn't find anything that could explain these to me in a manner that I would really get them. Then I started my free trial here and bam! All of a sudden so much stuff made sense... ;)