Hey guys,
I am struggling to center an image, I have the following code (without the end tag)… I am working on my tribute page for my first project! Thank you kindly in advance for any help
<img src="https://cdn.britannica.com/s:300x300/35/7535-004-99D14F9B.jpg" alt="Sir Winston Churchill" width=300 height=300 title="Churchill">
You could make the image display as a block, then add auto margins to either side.
img {
display: block;
margin: auto;
}
mcalex
May 28, 2019, 12:38pm
3
Do it in CSS. Don’t forget the ‘width’ attribute.
img {
display: block;
margin-left: auto;
margin-right: auto;
width: 40%;
}
Thank you! I know what I was doing wrong… i was misusing the CSS editor in codepen haha. Thanks!!
Thank you for taking the time to reply!!
you could also justify the content and select center