+ 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
8 Antworten
+ 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 😇
+ 6
It's very easy you have only to align the image to center when you are writing the code for inserting the image
+ 3
Add HTML:
<img src="path" alt="abc" class="center">
Add CSS:
.centre{
display: block;
margin-left: auto;
margin-right:auto;
width:50%;
}
+ 3
Arb Rahim Badsa another way
##HTML :
<div class="conatiner">
<img src="link.png">
</div>
##CSS :
.container
{
display: flex;
}
img {
margin: auto;
}
+ 2
You can use flex properties
+ 2
<img src=“path" alt=“abc" Align="center" />
+ 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..