0

How can I put the image in center

<html> <head> <title>first page</title> </head> <body> <img src="http://www.sololearn.com/images/tree.jpg" height="150px" width="150px" alt="" /> <br /> <img src="http://www.sololearn.com/images/tree.jpg" height="50%" width="50%" alt="" /> </body> </html>

12th Nov 2016, 6:27 PM
lo lo
4 Answers
+ 6
<html> <head> <title>first page</title> </head> <body> <div align="center"> <img src="http://www.sololearn.com/images/tree.jpg" height="150px" width="150px" alt="" /> </div> <br /> <img src="http://www.sololearn.com/images/tree.jpg" height="50%" width="50%" alt="" /> </body> </html> you can wrap each or both images in another div with align="center" you can also place the align="center" in the body tag, so everything is centered
12th Nov 2016, 6:35 PM
Burey
Burey - avatar
+ 6
align="center" property should do it!
12th Nov 2016, 6:39 PM
Riku Pepponen
Riku Pepponen - avatar
+ 3
A more simple way of centering a image is <center> </center> just put these on the out side ex: <html> <head> <title>first page</title> </head> <body> <center> <img src="http://www.sololearn.com/images/tree.jpg" height="150px" width="150px" alt="" /></center> <br /> </center><img src="http://www.sololearn.com/images/tree.jpg" height="50%" width="50%" alt="" /></center> </body> </html> It makes your life alot more simple. hope i helped :)
12th Nov 2016, 8:30 PM
Aquarius
Aquarius - avatar
+ 1
html img id="imag" src="http... css #imag{ width: 50%; heigth: auto; margin-left: 25%; }
12th Nov 2016, 7:58 PM
Eduardo
Eduardo - avatar