Center align single image

Hi. This is my first time to use CSS and what I wanted to do is align embedded image at the center.

Things I have tried

I saved the file centerImg.css which contains:

img {
  display: block;
  margin: 0px auto;
}

and applied with the line below:

<span class='centerImg'> ![[Pasted image 20210818115035.png]] </span>

This code aligned the image at the center.

However, the alignment occurred not only to the image that I want, but everywhere. How can I align specific images that I want only?

Thank you.

1 Like

change the img selector to .centerImg

1 Like

Thank you!

changing to

.centerImg img {
  display: block;
  margin: 0px auto;
}

works

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