+ 1

How do I center an image in HTML? I have tried the align attribute but it had no effect.

2nd Dec 2016, 6:22 PM
Kegan McAfee
Kegan McAfee - avatar
6 Answers
+ 4
* Set the parent tag "text-align" property to "center" Notices: <center> is deprecated in HTML5 "align" attribute is not supported in HTML5
8th Dec 2016, 6:36 PM
$machitgarha
$machitgarha - avatar
+ 3
<img src="yourimage.jpg" alt="" align="center"/> if you cannot get it,try below code <p align="center"><img src="yourimge.jpg" alt=""/></p>
2nd Dec 2016, 7:04 PM
Aung Aung
Aung Aung - avatar
+ 3
<figure align="center"> <img src="imagename.jpg" width="300" height="300"> </figure> <figure> is the HTML5 Tag which you need for an image "width" and "height" specifies the size of the image align="center" aligns the image in the center hope this helps ~Kamil
2nd Dec 2016, 7:20 PM
Kamil
Kamil - avatar
+ 2
Use these: <center>....</center> These tags are some much easier to use :)
2nd Dec 2016, 10:52 PM
Aquarius
Aquarius - avatar
+ 2
Ok when i tagged the image as <p></p> it worked as well as the <center></center> tags. I haven't tried the figure tag yet because I haven't really started working with html5 yet. Thanks everybody.
3rd Dec 2016, 9:36 PM
Kegan McAfee
Kegan McAfee - avatar
+ 1
Have you tried <img ... align="middle" ... >? Watch the reference on http://www.w3schools.com/TAgs/att_img_align.asp Hope, it helps. :)
2nd Dec 2016, 6:55 PM
Nils Domin
Nils Domin - avatar