Using CSS3 attribute selectors to align images in Markdown

If you are looking to align images in a pure markdown (no HTML) document you can use CSS3 attribute selectors to select images with a certain anchors in its path.

Example

Markdown

![Alt](image.jpg#right)

CSS

img[src*='#right']{ float: right; }

This way with a few lines of css you can use valid markdown to control layout.

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Leave a comment

Name Notify me of replies by email.