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 trialPeter Yin
Courses Plus Student 728 Pointsmargin centering
Hi, a bit confused on what margin really does and how I could center my wrapper with margin?
2 Answers
Reuben Varzea
23,182 PointsMargin is the white space around your object. So, if you were looking to center something, that "something", like wrapper, would itself need to have a size defined, and then you can assign values to the margins to center it. Keep in mind that if you don't know what the values should be for margin, there is a value you can use to cover yourself regardless of browser window size.
jake anderson
6,017 Pointsdefine a percentage width and height then use margin:auto; to center as shown below
.wrapper { position: relative; width: 80%; height: 60%; background: #00000; margin: auto; }