Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use multiple css classes in HAML?

Tags:

css

haml

If I am chaining multiple css classes where the HTML would come out looking like:

<a class="btn primary large">

How would I do this in HAML? These guesses didn't work:

.btn-primary-large
."btn-primary-large"
like image 336
Jeremy Smith Avatar asked Nov 01 '11 17:11

Jeremy Smith


People also ask

Can you have multiple CSS classes?

Multiple classes can be applied to a single element in HTML and they can be styled using CSS. In this article, we will stick to only two classes. But the concepts used in assigning two classes can be extended to multiple classes as well.

Can we use multiple classes in one tag?

HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.

What is HAML CSS?

Haml is a markup language that's used to cleanly and simply describe the HTML of any web document, without the use of inline code. Haml functions as a replacement for inline page templating systems such as PHP, ERB, and ASP.


Video Answer


2 Answers

Use dots instead of dashes:

.btn.primary.large
like image 157
Adam Lear Avatar answered Oct 20 '22 12:10

Adam Lear


Question didn't specifically ask for a Haml+Ruby solution, but here is one for those who are interested. It uses a literal array.

%a{ class: %w[btn primary large] }
like image 12
Viet Avatar answered Oct 20 '22 13:10

Viet