Center image using text-align center



Problems:

  • html img class - The problem is, is there any good way to center an html image tag using css ?
  • Is the property text-align: center;of img html5 will work?
img {
    text-align: center;
}

Solution 1:

  • That will not work as the text-align property applies to block containers, not inline elements, and html img is an inline element.

Use this instead in your img html :

img. Center {
    display: block;
    margin: 0 auto;
}

Solutions 2:

try the following solution for img tag

img {
    display: block;
    margin: 0 auto;
}

Solution 3:

  • Another way of doing would be centering an enclosing paragraph.
  • text-align: center is a good way to center an html image tag, and did not specify that the property had to be a part of the img tag.
<p style="text-align:center"><img src="..."/></p>

Solution 4:

You can do the following solution: text-align: for your html5 img tag

<center><img src="..." /></center>

Solution 5:

Here the solution is simply for your img tag html. change parent align.
Try this one on parent properties text-align:center



Related Searches to Center image using text-align center