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 trialGrace Ji
5,402 PointsWhy did he set text-align:center; to get the overlaid image center on css?
The overlaid image is not even text. Why did he apply text-align:center; to get the overlaid image on center?
2 Answers
Benjamin Larson
34,055 PointsThe text-align property is probably not the best name. If you read on MDN: text-align, you'll see that it applies to any inline element. Since images by default are inline-block elements, the text-center property is applied.
al76
6,053 PointsIn addition, as there is no float centre using a float won't work. However, if your image has display block on it you can also use margin:0 auto;
img {
display:block;
margin:0 auto;
}
Grace Ji
5,402 PointsGrace Ji
5,402 PointsAwesome. Thank you Benjamin!