Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Since we can only use Markdown and a limited subset of HTML/CSS is it possible to center an image, or any block element for that matter, on the Stack Exchange sites?

share|improve this question
If it DID support markdown, yes. It supports a subset of markdown, and not including the arrows to center text (->centeredText<-) – Camilo Martin Oct 27 '10 at 22:58
@CamiloMartin Markdown does not support centering text. Only Markdown variants do. Try ->center<- here. – Daniel Beck Apr 3 '12 at 17:31
@DanielBeck Ah, you're right, I think I was fooled by the fact other Markdown implementations support it. – Camilo Martin Apr 3 '12 at 21:58
I'm inclined to think that images (inside questions and answers) should better be by default centered - (wow, I can't believe it's almost 4 years since I asked for that...)… – leonbloy Jul 14 '15 at 19:24
up vote 12 down vote accepted

You could use the <pre></pre> tags to position things manually I guess, but that is the only way I can imagine doing so.



share|improve this answer
This wouldn't work very well with an image though. It would just show the Markup or <img> tag. – Ben S Oct 14 '09 at 14:29
@Ben S: So draw the image as ASCII art, then. Problem solved. – Hilarious Comedy Pesto Oct 14 '09 at 14:35
I see it does work with an image, but is there a way to not have the grey background? – Ben S Oct 14 '09 at 14:44
I settled on using a series of &nbsp;s to center without the background. – Ben S Oct 14 '09 at 14:46
Because until we see cornify, this sized pony will do. – random Oct 14 '09 at 14:54
Bronies?!? On a serious note, the lack of a center style/tag does seem like a curious omission, but I guess we all have our pet tags. ;) – Robert Ryan Nov 26 '12 at 19:30
This looks seriously broken and bad in the Android app.. – JonasCz Feb 24 at 10:14

TL;DR—Prepend as many &nbsp;s as you need.

After trying all the options at hand, your best bet is to "manually" center the image prepending as many &nbsp;s as you need.

The best example is when you include the graphic using Markdown synthax:

Using <pre>

        ![Dry Paint][1]

Using &nbsp;

                  Dry Paint

share|improve this answer
What about the mobile site, the data dumps, and whatever other ways post are used? Doesn't feel like a good advise to me... – Arjan Mar 30 '12 at 19:18
@Arjan, I've hit this link from my phone (Nexus S) and it looks good and centered. I guess it's my browser that just scales down the web version. How can I see the scenarios you mentioned? – Marius Butuc Mar 30 '12 at 20:18
Actually, the mobile CSS theme centers (and fits, if needed) all images, no hack needed at all. (And it "displays" the whitespace above the image.) I was just saying that one cannot center stuff using whitespace; it just adds noise I'd say, and it relies on some specific content width and font width. – Arjan Mar 30 '12 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .