Example you need to float a bunch of elements.
Option 1 – Chain elements
#elm1, #elm2, #elm3, #elm4 {float:left}
Option 2 – Add a similar class to elements
.float {float:left}
Option 3 – Add style to class individually
#elm1{float:left}
#elm2{float:left}
#elm3{float:left}
#elm4{float:left}
I prefer 1 but I don’t know how much of a speed impact it has, are there any other options? Whats the convention for this?
Most CSS minimizer and “cleaners” will do your first option. In my opinion, it’s much better than creating a new class to add to a bunch of elements just for style and it’s a million times better than your last option.
In CSS, if it already has an ID or a class, you can apply style to it. So, comparing option 1 to option 2, option 1 should be your better choice. You don’t have to go back through your code and add classes to elements that already have IDs and you don’t have to juggle style between the ID and the class for the same element in your stylesheet.