img {
text-align: center;
}
That will not work as the text-align property applies to block containers, not inline elements, and img is an inline element.
Put text-align: center on a containing block and as long as the image is still inline, it will be centered.
If the image itself is set to block then it must have left and right margins set to auto.