How to center an img

<style>
  .green-text {
    color:green;
  }
  .smaller-image {
    width:100px;
  }
</style>
<h1 class="green-text text-center">Karl Marx</h1>
<a href="#"><img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/freecodecamp/original/3X/8/c/8cb74b7339564360d451b4f3484be5340d0da18f.jpg' class="smaller-image"></a>

I can’t find a way to center the image on my project. I’ve tried this --> https://www.w3schools.com/howto/howto_css_image_center.asp and it didn’t work for some reason. Any suggestions?

By the way, I’m confused about the whole

thing. I want my code to be visible but it just shows as what it should look like…

just use this in your css pointing to your image container, or the image itself

.img{
width: 80%; /*I recommend using relative units like percentages*/
margin: 0 auto; /*0 value will be in top and bottom and the auto will set a uniform
 value as the margin of the container or the image for left and right thus, aligning it to center*/
}

Thanks for the suggestion. Turns out I was being stupid and wasn’t clicking the run button. I feel really dumb. Thanks!

<center><image src=""></center>

However, if you want the image load faster, you could try AMP.
Check out all the image in my website, which is coded in AMP,

Here, i found it usefull and handy https://css-tricks.com/centering-css-complete-guide/