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

The quiz is asking me to center the id #wrapper using a "margin" property. This was not covered. We covered text-align

This is Task 2 of 3 in Stage 4: CSS

Try text-align: center in some cases it works but you should use margin: 0 auto. All things are covered in the topics. :)

1 Answer

Hi Travis,

It should have been covered in the video but try adding the following to your #wrapper style (which already includes a width less than 100%)

margin: 0 auto;

Thanks

-Rich

In my personal experience (could be wrong), aligning with margins only works when you have also declared a width to the element you're wanting to center.

#wrapper {
    width: 100%;
    margin: 0 auto;

}

Someone please let me know if I'm wrong on this...

Margin auto can be used on block elements, but is only useful on elements whose width is less than 100%. At 100% the element fills the full width of its parent, which means it is already centered.

Hi Brent,

You are correct sorry (that'll teach me to try to answer quickly on my phone). Just updating my answer although it would need to be less than 100% to have an effect :)

-Rich