How to center an img

  .green-text {
  .smaller-image {
<h1 class="green-text text-center">Karl Marx</h1>
<a href="#"><img src='//' class="smaller-image"></a>

I can’t find a way to center the image on my project. I’ve tried this --> 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

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!

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


<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