How can I set alignment for image? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can I set alignment for image?

20th Jun 2016, 8:32 PM
Saeed Mashhadi
Saeed Mashhadi - avatar
6 Answers
+ 2
You have to use CSS. The align attribute is not supported in HTML5. To center an image, you have to make it into a block element and give it margin auto: <style> .centered { display: block; margin: 0 auto; } </style> <img class="centered" src="my_img_url"/>
21st Jun 2016, 11:23 PM
ZinC
ZinC - avatar
0
Depends on what you want to achieve. Can you tell us more?
21st Jun 2016, 12:43 AM
ZinC
ZinC - avatar
0
<img src="" align="left/right/bottom/up">
21st Jun 2016, 5:52 PM
keval gajjar
keval gajjar - avatar
0
@ZinC I want to display the image in center of the webpage. I used <img src="my_img_url" align="center"/> but it doesn't work. (the image is in left side yet)
21st Jun 2016, 8:43 PM
Saeed Mashhadi
Saeed Mashhadi - avatar
0
I need to know how ?
22nd Jun 2016, 11:52 AM
beshoy osama
beshoy osama - avatar
- 2
<center> <img src="img_url"> </center>
22nd Jun 2016, 5:16 PM
Ibraheem Mahmood
Ibraheem Mahmood - avatar