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 How to Make a Website CSS: Cascading Style Sheets Style the Basic Elements

Aida Mimii
Aida Mimii
395 Points

Not sure what I did wrong in this Code Challenge?

Okay, so, the challenge is asking me to "select the ID wrapper, set it to a max of 940 pixels, and then center it on the page using the margin property. It's giving me an error:

"Bummer! Check the max-width value in your CSS."

Here is my code:

a {
  text-decoration: none;
}

#wrapper {
    max-width: 940px;
    margin: 0 auto;
}

Could someone tell me what I've done wrong?

6 Answers

Stone Preston
Stone Preston
42,016 Points

try it again. I pasted your code in and it worked just fine. Here is what I used:

a {
  text-decoration: none;}

#wrapper {
    max-width: 940px;
    margin: 0 auto;
}
Aida Mimii
Aida Mimii
395 Points

Haha, nevermind then. I guess it was just some glitch for me. It's working now.

David Andrews
David Andrews
17,403 Points

I Guess the problem left then is inconsistency and a decent error message on this particular question.

Why should max-width : 940px; be valid but margin : 0 auto; not be?

Nick Pettit
Nick Pettit
Treehouse Teacher

It probably has nothing to do with the specific properties that you're using. What's more likely is that language tokens are being interpreted unpredictably due to the syntax errors. If you've ever accidentally left an HTML element open without a closing tag, you'll see it close when it reaches the next corresponding tag. I believe something similar (although probably not exactly the same) is happening here.

David Andrews
David Andrews
17,403 Points

According to the W3 CSS spec white space is valid between the declaration name and the value - so this is not a syntax error. I am guilty of having it across all of my CSS files and they work perfectly well.

If you want to teach convention, I don't disagree, but it should be consistent.. I have passed many CSS code challenge on Tree house having white space on both sides of the colon - failing for this reason on 1 question was time consuming in trying to work out where it was wrong with an arbitrary error message.

Nick Pettit
Nick Pettit
Treehouse Teacher

According to the W3 CSS spec white space is valid between the declaration name and the value - so this is not a syntax error.

Wow, I didn't know that! Interesting. :)

Thanks for bringing this to our attention. I'll file a ticket for it with our developers so they can look into either allowing it to validate or creating better error messages. It could be impossible due to the way code challenges are parsed and evaluated, but we'll do our best.

Nick Pettit
Nick Pettit
Treehouse Teacher

OK! This should be fixed now. Thanks again for pointing it out. :)

David Andrews
David Andrews
17,403 Points

Great stuff - cheers for picking it up so quick!

Brittni Kelly
Brittni Kelly
1,250 Points

I am running into the same issue, except that mine does not have the spaces. It matches up with exactly what Stone Preston's post shows above. I just want to move forward. :(

David Andrews
David Andrews
17,403 Points

I was fighting with this for ages... seems it doesn't like it if you have a space between margin and ":"

So

#wrapper {
     max-width : 940px;
     margin : 0 auto;

Is not passing the test...

but

     margin: 0 auto;

does pass, needs looking at Nick Pettit

Nick Pettit
Nick Pettit
Treehouse Teacher

I don't think CSS should parse if the colon language token has a space before the property name. Even if that's technically correct, I've never seen this in practice, so I'd rather it not be marked as correct purely as a matter of convention.