Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Using Margin to Center the Wrapper Text?

Still not understand the question "Select the Wrapper Element, and then center it on the page."

The correct answer was:

```#wrapper { margin: 0 auto; }

How does this center? I didn't use the attribute center?

2 Answers

Joseph Wachira
Joseph Wachira
17,972 Points

"margin: 0 auto;" means that the top and bottom margins will be zero. The auto tells the browser to split up the horizontal space evenly between the left and right margins thus resulting to a centered wrapper.

The center attribute is used for centering text.

Refer to this doc → centering things

Hope that helps.

Happy learning :)

Ricky Catron
Ricky Catron
13,023 Points

The word auto puts a equal margin on both sides of whatever wrapper is connected to. This effectively moves the element to the middle of the page. The atribute center only works for text-align if instead you wanted to center a picture or div you would use this.