steven_noble steven_noble - 4 months ago 14
CSS Question

How do you add more than one css class to an <img> using image_tag?

How do you add more than one css class to an

<img>
using image_tag?

Using
image_tag("image.png", :class => "class1, class2")
seems not to work

Answer

Don't separate the classes using a comma, separate them using a space...

image_tag("image.png", :class => "class1 class2")

Note: You cannot use a space inside a class name...separate them using _ or -, if you use space than class 1 class 2 will be like 4 classes in which all are invalid.