Text-align is not working on a img tag
-
20-04-2021 - |
Question
Take a look at my fiddle: http://jsfiddle.net/jVsQY/
As you can see, I'm using text-align: center
on a image tag, with a class and it doesn't show any results.
I was trying using an display: inline-block
and so, but did not helped.
Solution
To center align an image you need to do something like this:
<div style="text-align:center;"><img src="image.jpg" /></div>
Or like this:
<img src="image.jpg" style="display:block; margin:auto; "/>
OTHER TIPS
If you use this CSS you will get the image centered
.center { display: block;
margin-left: auto;
margin-right: auto;}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow