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 trialmustafa
1,566 PointsTreehouse 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
11,798 PointsHi, 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>
Anusha Singh
Courses Plus Student 22,106 PointsHi, 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>
Anusha Singh
Courses Plus Student 22,106 PointsHope this was the solution towards your problem
mustafa
1,566 PointsThanks a lot, appreciate it.
Tanja Schmidt
11,798 PointsGlad I could help! :)
mustafa
1,566 PointsI noticed in your profile that you registered in April this year. Were you starting from scratch? Your progress is really impressive:)
Tanja Schmidt
11,798 PointsThanks 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... ;)
mustafa
1,566 Pointsmustafa
1,566 PointsThat worked great. Thanks so much for your help, really appreciate it:)