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

HTML How to Make a Website CSS: Cascading Style Sheets Center the Wrapper

haakon Guttormsen
haakon Guttormsen
2,157 Points

styling issues

Hi, I am doing the follow along on "how to make websites". In one of the first styling steps I am supposed to style a div-tag named wrapper. In CSS I write the following css-rule: wrapper{ max-width: 940 px; margin: 0 auto; background : orange ;
} When Nick refreshes hes browser he get a space between the orange colored div-area and the sides of the browser. When i do the same code the orange area is going all the way to the sides of the page.

I add a link to the snapshot here: https://w.trhou.se/wpz6283jbf

Why do I not see the div-area the same way as Nick does?

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey there,

There could be a couple of possible reasons:

  1. First, in the CSS above that you provided, you have just wrapper. You mention that you are to style a <div> "named" ... but tags don't have "names" in that sense. The word div is the name of the tag, then tags can have an ID or a class. If I remember correctly, this lesson asks for styling on the <div> with the class wrapper. Now remember, classes are selected in CSS by prefixing the class name with a # symbol (which is missing in your CSS above).

  2. When I look at your Workspace snapshot, there is nothing in the CSS folder. So, maybe you didn't save the file before trying to preview?

Check out those two things and see if that fixes the problem.

Hope that helps. :dizzy:

haakon Guttormsen
haakon Guttormsen
2,157 Points

Thanks for replying.

I sent you the wrong link. Here is the correct one: https://w.trhou.se/x8ltm1x4k8

As you can see I use the "hash" in front of wrapper in my css. I have also saved it so it has to be something else.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi,

I got your corrected link.

In your #wrapper rule, you have max-width set to "940 px" with a space. While white space doesn't usually affect CSS, there are some exceptions. This is one of them. Just remove the space (so you have 940px) and save and refresh and it works.

:) :dizzy: