Centre an Image

Steffan's Avatar


08 Jul, 2014 02:12 PM


I am looking to centre images once they are pushed to a Web site (or rendered to a .pdf). My current objective is to export my .md to Squarespace. The default in the included CSS templates seems to be to left justify images.

I have tried using:

IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto }

from w3.org by applying it both to Style|Additional CSS and editing the default CSS template and editing it there.

It seems to have no effect on Marked's output. I tested it by exporting the .md via Byword to my tumblr - no luck.

Any ideas?



  1. Support Staff 1 Posted by Brett on 19 Jul, 2014 12:50 PM

    Brett's Avatar

    IMG.displayed is not a valid selector for images in Marked. If you want to center all images, you can just use:

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

    or similar. If you want to center specific images, you'll have to wrap them in HTML with a custom class.

  2. 2 Posted by Steffan on 30 Jul, 2014 09:23 AM

    Steffan's Avatar

    Hi Brett,

    I tried that with no luck :^(


  3. 3 Posted by josh on 11 Dec, 2015 04:09 PM

    josh's Avatar

    I just tried, too, and it didn't work for me, either. Is there something else I can try?

  4. 4 Posted by Ehler on 17 Aug, 2020 04:51 AM

    Ehler's Avatar

    For anyone coming to this thread five+ years later, you need to edit the CSS on the figure element, not the img element.

  5. Brett closed this discussion on 25 Sep, 2020 04:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac