Css class not working in markdown

Hi,

I’m trying to add a css class in markdown, I’m using Kramdown.

This is my attempt:

<div class="rightalign">![alt text.](/image.jpg)
</div>

The markdown works on its own (it displays the image), but when I add the div it doesn’t.

Any ideas would be great!

1 Like

I think you can add a class to the actual image element like this:

![alt text.](/image.jpg) {: .my-cool-class }

https://kramdown.gettalong.org/quickref.html#block-attributes

Not sure about the way you are doing it by wrapping the image in a div and giving the div the class.

1 Like

rdyar is right

![alt text](/image.jpg){:.css_class}

works.

But the confusion is understandable since when dealing with texts the class spec should be placed in front (at least that is my experience):

{:.css_class} My line of text

Regards,
Rien.

1 Like

Thanks Rdyar.

Probably worth noting that if there’s a space between the closing bracket and the curly brace it doesn’t work (at least for me anyway).