Young just to clarify, the tag <img>
doesn’t need to be closed, so this is wrong <img></img>
(Image is an element of type "Void" it can not have anything inside, another example is the <input>
which also has no closing tag </input>
)
Now on your question one of the options you can make is to put the image inside a <div>
who is with display:flex
and use the properties of flex to align what’s inside horizontally with justify-content:center
and vertically with align-items:center
Take the example:
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
.holder {
display: flex;
justify-content: center;
align-items: center;
}
.holder img, .holder p {
position: absolute;
font-size: 32px;
font-family: sans-serif;
text-align: center;
}
<div class="holder">
<img src="https://marketingdeconteudo.com/wp-content/uploads/2017/01/formatos-de-imagem-2.jpg">
<p>Texto que deve <br>ser alinhado!</p>
</div>
Related: https://answall.com/q/162510/99718
– Valdeir Psr