+ 7

How can i paste an image in middle in html

I want to set an image in html https://www.sololearn.com/discuss/1795204/?ref=app

11th May 2019, 4:19 AM
Prahlad Gaur
Prahlad Gaur - avatar
8 Answers
+ 8
Prahlad Gaur It's easy to center a image! To make the code look better, we can create a container and put the image in it. For example : ##HTML : <div class="container"> <img src="link.png"> </div> ##CSS : .container { height: 100vh; width: 100vw; display: flex; justify-content: center; align-items: center; } All the contents inside the container class will be in the middle both horizontally and vertically 😇
12th May 2019, 4:03 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 6
It's very easy you have only to align the image to center when you are writing the code for inserting the image
21st May 2019, 11:29 AM
Arush Singh çöďëŕ äñď ďévëľöpęŕ
Arush Singh çöďëŕ äñď ďévëľöpęŕ - avatar
11th May 2019, 5:13 AM
Calviղ - avatar
+ 3
Add HTML: <img src="path" alt="abc" class="center"> Add CSS: .centre{ display: block; margin-left: auto; margin-right:auto; width:50%; }
12th May 2019, 2:54 AM
Kiran - avatar
+ 3
Arb Rahim Badsa another way ##HTML : <div class="conatiner"> <img src="link.png"> </div> ##CSS : .container { display: flex; } img { margin: auto; }
12th May 2019, 4:19 PM
Calviղ - avatar
+ 2
You can use flex properties
11th May 2019, 6:25 AM
Imdad Hussain Mamud
Imdad Hussain Mamud - avatar
+ 2
<img src=“path" alt=“abc" Align="center" />
11th May 2019, 10:38 AM
Jaspreet Singh
Jaspreet Singh - avatar
+ 2
You need to use a <div> or <p> tag having your image within these tags and then you can use attribute align="center" on your <div> or <p> tag Or you can set a class and define CSS for placing image in center..
12th May 2019, 10:53 AM
Mohd Ashraf Shaikh
Mohd Ashraf Shaikh - avatar