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 trial

CSS CSS Foundations Selectors Basic Attribute Selectors

CHIAHUI HSIEH
CHIAHUI HSIEH
1,965 Points

When I typed [class] {background-color:crimson}, the whole page background becomes crimson.

When I typed [class] {background-color:crimson}, the whole page background becomes crimson.

4 Answers

geoffrey
geoffrey
28,736 Points

It would be better for us if you could post the entire code, this way, we could spot the mistake easily !

Here is an exemple, I applied the crimson to a class as you suggested in the small exemple you typed.

http://codepen.io/Azuk/pen/asJfo

If you don't find the mistake, post your code :) !

Did you really typed... [class] ? If you typed that, then that is the reason why. Try using the class selector name instead. For example if the class has the value... customers... ie.

class = "customers" - select it this way

.customers{
background-color: crimson;
}
Mark Phillips
Mark Phillips
13,124 Points

OP, you are correct. In the video for this tutorial Guil clearly types

[class] { background-color: crimson; }

And it does indeed target all anchors with a class attribute in them and make them Crimson. However when following this tutorial, my result is the same as yours.

I was following along via CodePen.

When I did this in Sublime Text 2, the class attribute works properly and targets every element on the page with a class attribute.

Perhaps it's a bug within CodePen?

Hernan Martin Demczuk
Hernan Martin Demczuk
1,264 Points

I didn't see the code, but I'd check if the body element has a class attached