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
Christopher Anderson
1,601 Pointshow can I center this element
<iframe width="560" height="315" src="https://www.youtube.com/embed/MyqtIdSSlS0" frameborder="0" allowfullscreen></iframe>
2 Answers
Steven Parker
243,656 PointsWithout seeing the code, I can only give you some generic suggestions.
For a block element, give it a specific size and auto margins, and for an inline element, give it the text-align property with the value center.
.center-block {
width: 100px; /* set this to the size of your content */
margin: auto;
}
.center-text {
text-align: center;
}
Milan Nikolic
24,365 Pointsyou can center element like this
.center-element { display:block; margin: 0 auto; width:100px; }
Steven Parker
243,656 PointsSteven Parker
243,656 PointsIt would help if you posted your code, or even better, a snapshot of your workspace.