B2B Marketing Insights by Ironpaper

Assign Two CSS Classes Together For One Object

Written by Ironpaper | July 08, 2010

It is possible to assign an object two or more classes at the same time. WordPress does this out of the box for images, for example.

<img class="alignnone size-full wp-image-144"

We used color coding of each class to detail each class applied to the image tag. To add multiple classes, simply separate each class with a space (not a comma). In the case above, the image will use the rules for both "alignnone" and "size-full" as well as "wp-image-144."

This can be useful if you are using a CSS grid framework or if you have created your own CSS primer style sheet, which requires further customization. It will allow you to leave the framework untouched while you can add further specifications or style to the second class. This way, classes can be reused and recycled.