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 trialDidier Borel
2,837 Pointsdiv class
hi where does one define the div class? i am putting it below the <div> command. that is not workingg
<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
Didier Borel
2,837 PointsI am sorry I don't understand. why is what I have written above incorrect. i.e why is my code incorrect. ? what is the proper way to define the div class for both of the div? this
Gunhoo Yoon
5,027 Points 1 <div>
2 <div class="favorite stuff">
3 <h4>Favorite Foods?</h4>
4 <input name="food[]">
5 <input name="food[]">
6 <input name="food[]">
7 <input name="food[]">
8 </div>
You have 3 errors.
1 Look at line number 2.
This div element has no closing tag. HTML elements usually needs opening and closing tag like <div></div> unless they are something called void element like <input>. So your div tag at line 2 is syntactically wrong. You can fix it by putting closing div tag but there is better solution.
2 You don't need to use extra div
Look a t line number 1 and 8 there is two empty div without any meaning. You can just define your class there.
3 Look at your class definition class="favorite stuff"
Space character is used to separate class name. class="favorite stuff" means two different class names "favorite" and "stuff". However, the question asks you to use single class name "favorite_stuff" which has underscore instead of space.
If you don't have knowledge in basic html it will be harder for you to use JavaScript as web language so learn html basics first.
Didier Borel
2,837 Pointsthxs for your answer. I was tied up at and couldn't respond earlier.
basically I have rewritten it with the _ i.e "favorite_stuff" and I have put the <div class="favorite_stuff"> after the <div> on line 1 (on the line above <h4> favorite foods) and lower, below the <div> <h4> favorite animals? <h4> and I still get an error message. I don't understand why.
thxs for your help
Didier Borel
2,837 PointsI am sorry I don't understand. why is what I have written above incorrect. i.e why is my code incorrect. ? what is the proper way to define the div class for both of the div? this
Gunhoo Yoon
5,027 PointsI edited my answer refer back to it.
Gunhoo Yoon
5,027 PointsI don't know what you are doing but you really should know the basics of html syntax.
I'm posting answer because your are still in trouble.
<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>
Didier Borel
2,837 Pointsthxs , I got it now,