+ 2
How do you center an img?
i cant get it
5 Answers
+ 3
@Chris James img {text-align: center} will not align the image to the center because it aligns all the children and the content of the tag only. <div><img></div> with div {text-align: center} will.
+ 1
text-align: center;
will also center images
+ 1
@cheese, u r stating the obvious.
<center> tag is not supported in html5
+ 1
Don't use the align attribute as that is deprecated in HTML 4 and marked as obsolete in HTML 5. Use Flexbox if you are targeting a remotely modern browser. Otherwise you should be able to use something like this:
.my-img {
display: inline-block;
margin: 0 auto;
}
0
You can add a css "class"
.center {
text-align: center;
align-content: center;
}