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 trialoren tal
5,738 Pointsstuck in a quiz
well, this is the question i cannot pass even though ti look easy i don't know much about divs and couldn't put the class attribute in the right place. please help
We want the same CSS style to apply to both <div> elements. Give both <div> elements the class of "favorite_stuff". Hint: The syntax for giving a <div> a class looks like this: <div class="favorite_stuff">
1 <body> 2 <h1>First Day of School</h1> 3 ā 4 <form> 5
6 <div> 7 <h4>Favorite Foods?</h4> 8 <input name="food[]"> 9 <input name="food[]"> 10 <input name="food[]"> 11 <input name="food[]"> 12 </div> 13
14 <div> 15 <h4>Favorite Animals?</h4> 16 <input name="animal[]"> 17 <input name="animal[]"> 18 <input name="animal[]"> 19 <input name="animal[]"> 20 </div> 21 ā 22 </form> 23 ā 24 </body>
1 Answer
Leigh Luerman
17,623 PointsWhen you're adding classes to HTML tags you just add them as attributes. For example, if you wanted to an anchor tag with a class of "home-link" you would type out this:
<a class="home-link"></a>
(of course that link won't go anywhere because it doesn't have a src attribute but I just wanted the class example)
You can assign classes to just about any HTML tag this way, including your divs.
MOD NOTE: Changed to Answer from Comment. This way it can be up-voted/marked as Best Answer.