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

how to use a 'div' tag

I don't understand when it tells me i need a class element after the <div tag. I have the class element there with the quote "favorite_stuff"

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="faorite-stuff"
      <h4>Favorite Animals?</h4>
      <input name="animal[]">
      <input name="animal[]">
      <input name="animal[]">
      <input name="animal[]">
    </div>

  </form>

</body>

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Amaya and Welcome to Treehouse.

You're on the right track, but you added a whole new <div>, when the challenge just wanted you to add the class to the two that were already there. Also, in your code, you are missing a closing tag on the 2nd div.

You need to delete the 2 div tags you added (or refresh the challenge) and just add the classes.

The completed code will 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>

Hope that helps to clear it up. Keep Coding! :)

Thank you for your help!

so a <div> is just an invisible box that you use to build the page, only you can make the box look how you want. :) the reason you want to have "class"s and "id"s is you are giving <div>s <h1>s and other DOM elements names in order to manipulate them with other code like jQuery and css3.

css3 needs to know what element or elements you are talking about when you style them.