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

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.