Reputation: 10004
I want to apply a style to all <p>
and <input>
elements of the numeric
class using css.
Is it possible to consolidate this so that I only write "numeric" once?
p.numeric,input.numeric {
float: right;
}
I'm also using sass, so if it's not possible in CSS is it possible with the sass additions?
Upvotes: 9
Views: 20699
Reputation: 5203
yes it is possible:
p, input {
&.numeric {
float: right;
}
}
The '&' is necceassry to connect with p/input. Without the result will be p .numeric {...}
Upvotes: 25
Reputation: 31730
You could simply do .numeric, but then it would apply to everything with a class of numeric. If you only want it to apply to paragraphs and inputs then what you're doing is the correct approach.
Upvotes: 1