RelativelyMediocre
RelativelyMediocre

Reputation: 13

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?

Upvotes: 1

Views: 58

Answers (1)

Oliver Ni
Oliver Ni

Reputation: 2664

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>

Upvotes: 1

Related Questions