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 trialWinston Quin
10,359 PointsI copied the code in my workspace, saved, and clicked preview in browser, but none of the CSS selectors did anything
Not sure what I'm doing incorrectly here... Anyone see something I don't?
Winston Quin
10,359 PointsI am curious, is this a common mistake in CSS?
Jennifer Nordell
Treehouse Teacherwinston quin First, I'm going to change your comment that contained your solution to an answer. Because you did, indeed, answer your own question.
Yes, this is a common mistake. CSS can be very picky about whitespace. For instance, it doesn't really matter if you have a blank line after your opening and closing curly braces. But when writing a selector, spacing is a make or break deal. Don't worry, I'll bet 99.9% of us have done it
2 Answers
Winston Quin
10,359 PointsActually I just figured it out. I was including spaces that shouldn't have been in there. Rrrr... this is a nitpicky error.
here was my code when it wasn't working:
form [class="form-contact"] {
padding: 20px 24px;
background: #f4f7f8;
}
div [id="container"] {
max-width: 500px;
margin: auto;
}
Here's the correct code, with spaces between the "form"/"div" and square brackets removed:
form[class="form-contact"] {
padding: 20px 24px;
background: #f4f7f8;
}
div[id="container"] {
max-width: 500px;
margin: auto;
}
Moderator edited: Changed to an answer and markdown applied so that code renders properly in the forums.
Jennifer Nordell
Treehouse TeacherTbc, this isn't just an error specific to Treehouse. This is how this code works. A space in your selector in the wrong place will break it.
Winston Quin
10,359 PointsThanks for the clarification!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi there! This would be easiest to resolve if we could see a snapshot of your workspace so we can fork it and have a look around. But before we go through all that, have you tried viewing the same page after clearing your browser cache or viewing in a private tab? There is always the possibility that your browser is loading in an older version of your code than what you're trying to view.