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 trialTravis Chaney
3,297 PointsThe 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
1 Answer
Rich Bagley
25,869 PointsHi 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
Brent Cralley
18,541 PointsIn 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...
eck
43,038 PointsMargin 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.
Rich Bagley
25,869 PointsHi 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
Stoyan Stoyanov
Courses Plus Student 2,061 PointsStoyan Stoyanov
Courses Plus Student 2,061 PointsTry text-align: center in some cases it works but you should use margin: 0 auto. All things are covered in the topics. :)