+ 2
How can I center a image?
Hello people of SoloLearn, I have been learning about HTML, when I was practicing the images and hyperlinks i cannot center the image, can someone help me with that? https://code.sololearn.com/Wyyid3ECVvje/?ref=app
3 Antworten
+ 2
Here's an example code of how to center an image.
Just add <p> around it and add style="text-align:center" to the tag. You can also set p's text-align attribute in the CSS tab.
<p style="text-align:center"><img src="image link" /></p>
+ 1
but this is not a good idea, I think. You can center any image by centering div element by margin auto with some particular width.
+ 1
Both give you the same output, but div is a bit bigger whereas <p> wraps around the image without any trouble. Using paragraph is the best, simplest way, in my opinion, without having to go through extra steps to fix the size of the div.