+ 2

How to align img to centre

16th May 2017, 4:29 PM
Akhil Raghav
Akhil Raghav - avatar
7 Antworten
+ 7
img { display: block; margin: 0 auto; } or <div style = "text-align: center"> <img src "..."> </div>
16th May 2017, 4:35 PM
Maz
Maz - avatar
+ 6
<div align = "center"> <img src "..."> </div> This is in pure HTML, works well but it's deprecated, so... use CSS instead. ;)
16th May 2017, 4:44 PM
Maz
Maz - avatar
+ 5
There is a HTML <img> align Attribute but it aligns the image just according to the surrounding element! but the HTML align attribute is not supported in HTML5 so you should use css for the alignment! the best solution is to put it into a div tag like Maz already explained!
16th May 2017, 4:45 PM
Cubensis
Cubensis - avatar
+ 4
@Akhil why do you think that HTML and JS really ends?
16th May 2017, 5:30 PM
Cubensis
Cubensis - avatar
0
I want answer in html
16th May 2017, 4:41 PM
Akhil Raghav
Akhil Raghav - avatar
0
tq
16th May 2017, 4:45 PM
Akhil Raghav
Akhil Raghav - avatar
- 1
HTML ends... CSS starts... JS really ends ^^
16th May 2017, 5:05 PM
Carson
Carson - avatar