HTML: image using 2 style attributes in one element

What I want: My image to be resized and centred.

What's happening: The image is resized, but not centred

My code:

< img style="text-align:center;width:204px;height:204px;" src="image.jpeg" >

What am I doing wrong and how can I prevent this happening with other elements?

1 answer

  • answered 2017-08-12 09:26 Oliver Ni

    Your text-align: center; should be placed on the parent element, not itself.

    <div style="text-align: center;">
        <img style="width: 204px; height: 204px;" src="image.jpeg">
    </div>