I've been looking at the markdown syntax used in GitHub for a while but except resizing an image to the extent of the readme.md page, I can't figure out how to center an image in it.
Is it possible? If it is, how?
I've been looking at the markdown syntax used in github [...], I can't figure out how to center an image
TL;DR
No you can't by only relying on Markdown syntax. Markdown doesn't care with positioning.
Note: Some markdown processors support inclusion of HTML (as rightfully pointed out by @waldyr.ar), and in the GitHub case you may fallback to something like <div style="text-align:center"><img src="..." /></div>
. Beware that there's no guarantee the image will be centered if your repository is forked in a different hosting environment (Codeplex, BitBucket, ...) or if the document isn't read through a browser (Sublime Text Markdown preview, MarkdownPad, VisualStudio Web Essentials Markdown preview, ...).
Note 2: Keep in mind that even within the GitHub website, the way markdown is rendered is not uniform. The wiki, for instance, won't allow such css positional trickery.
Unabridged version
The Markdown syntax doesn't provide one with the ability to control the position of an image.
In fact, it would be borderline against the Markdown philosophy to allow such formatting, as stated in the "Philosophy" section
"A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. "
Markdown files are rendered by github.com website through the use of the Ruby Redcarpet library.
Redcarpet exposes some extensions (such as strikethrough, for instance) which are not part of standard Markdown syntax and provide additional "features". However, no supported extension allow you to center an image.
Thank you, I solved by over-sizing the image. Pity for their bandwidth but they left me no choice
This works just fine:
<img align="..." src="..." alt="...">
@JohonnyPauling, if you are worried about not using too much github bandwith, you can give a look to Raw Git, that serves files stored on GitHub, caching them on their system. So, just one access is performed on the resource on GitHub, saving their bandwith.
Original markdown processes markdown syntax within span tags. So some thing like the following should work:
<span style="display:block;text-align:center">![Test Automation]Automated-Testing.png)</span>
The
align
attribute on animg
tag is deprecated as of HTML 4.01 and obsolete as of HTML5.