Skip to content
← Back to Community
Center image
Profile icon
KamronGorney

Can you tell me how to center an image i've been trying for hours and i still can't find out how to can someone please help me with my troubles

Answered by PYer [earned 5 cycles]
View Answer
Voters
Profile icon
GopalKumar11
Profile icon
AlekssIvanovs
Profile icon
9875987
Profile icon
Tati0697
Profile icon
MakiahHaynes
Profile icon
eliasbarba
Profile icon
ReginaTsang
Profile icon
Kurea0323
Profile icon
AsserAbdelhamid
Profile icon
PKBalan
Comments
hotnewtop
Profile icon
PYer

set the margins to auto and the display to block then add it as a class to the image element.

.center { display: block; margin-left: auto; margin-right: auto; width: 50%; }

then do <img src="image.jpg" alt="image" class="center">
Please mark this comment as the answer