0
how to align images to center in html
align="center" doesn't work
10 Answers
+ 2
key to understanding is that img is an inline element. best way imo is to wrap img with a div, a block element and a meaningful id attribute. then use css to center content in the div. dont use html align attribute. alignment is a styling issue. use css for styling. html to describe content.
html...
<div id="centerimg">
<img src="img.jpg" alt="alttext">
</div>
css...
#centerimg { text-align: center; }
0
thanks fr answering
can't be done using html??
just started cssđđ
0
then use align=middle
0
align="middle" works??
0
yup... check na
0
doesn't work
0
you know what.. first check your source of img... an img source must end with img file extensions.. like jpg, png, jpeg.. please
0
image is loading bro, no problem there. i have reduced the size to see the alignment. it is not compulsory that the src must end with jpg, png,
0
Hi kumar keshav,
Try replacing align="middle" with style="margin: 50%;"
This should provide centering both vertically and horizontally with respect to the block.
I hope this helps! :)