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 trialScott Bailey
13,190 PointsSelector Problem - Using previous video with this one
When following this video (and the previous one) I noticed an issue when using the selectors.
In this video he eddited the class "form-contact" using this selector:
.form-contact {
padding: 20px 24px;
background: #f4f7f8;
}
Then added this class selector and then added the class to the HTML to create a border-radius.
.br {
border-radius: .5em;
}
This is the HTML
<form class="form-contact br">
This all works fine.
But when you use the selector from the previous video, and then add the .br class it completly removes the background for the .form-contact class. (Using the same HTML).
Previous selector:
form[class="form-contact"] {
padding: 20px 24px;
background: #f4f7f8;
}
I read the docs but I can't find a reason why is does this...
Does it have anything to do with the attribute selector string class="form-contact" not able to be matched once we put the "br" in there as well?
Can anyone shed some light?
1 Answer
Steven Parker
231,110 PointsYou're right, the "=" in the attribute selector requires an exact match of the entire class setting. The way to combine the tag and the class in the selector without making it exclusive would be like this:
form.form-contact {
Scott Bailey
13,190 PointsScott Bailey
13,190 PointsThank you, I had a feeling it would be an exact match so thank you for confirming and expanding on it