Custom HTML - How to Center an image?

Highlighted
Tourist
6 0 1

Hi I've used the following code.

<div style="text-align:center">
<img src="https://cdn.shopify.com/s/files/1/666/666/9139/files/aaa.png?v=1587954210">
</div>

 

But still doesn't seems to be working. Any suggestions please. Thank You.
Capture.PNG

1 Like
Highlighted
New Member
1 0 0

I had this same problem and I fixed it with inline CSS that sets the display type to a block inside the <img> element. The "text-align: center" solution that is commonly suggested doesn't apply to images because... well, it's for text alignment rather than images.

 

<img style="display: block; margin-left: auto; margin-right: auto; width: 50%" src=(whatever your actual source is)>

 

You can change how large the image is with the "width" property.

 

0 Likes