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 trialShadab Khan
5,470 PointsClass selector targeting labels?
Hi Guil,
Why is the class attribute selector in the form also targeting the labels in the form? for e.g. Name, Email, Message..etc. I can see them change their font-color to Red after we style the form elements with [class] attribute selector.
Regards,
-Shadab.
1 Answer
Jonathan Newman
5,219 PointsBecause by typing [class] {color: red;}
we are choosing everything with a class. This includes everything in the <form> element in your HTML: h1 (Contact), <label> Name:, <label> Email:, etc
Look at line 12 in your html file. It clearly shows that <form class="form-contact">. By choosing everything with a class, it chooses everything in this form.