How to center a image using CSS

I’m coding my Tribute Page, but I don’t know how to center the image. Please help me.

What have you tried so far? Can you please provide a link to your current codepen?

1 Like

Hey Jeremy, thanks for the help but I alredy got. I copied the code from freecodecamp example.

You should not copy code from the sample projects.

1 Like

Good thing that you solved it, but just copying the code without understanding the concept is bad (unless you know what the concept is but lazy to code it.)

Try googling about CSS centering you’ll get multiple results of centering a text, an image, a <div> etc.

3 Likes

sorry, I misspoke. I didn’t copy the code, but I adapted it to my situation and researched the “display: block” property so that I could understand my code.

1 Like

Paste this code where you want

<div style="align-content: center; margin: auto; text-align: center;">
<img src="your-image.jpg">
</div>
1 Like

I would not research any code inside of those sample projects.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.