Posted By

michellebracken on 08/18/11


Tagged


Versions (?)

Setting Multiple Classes on an HTML Element


 / Published in: CSS
 

Easy and easy to forget the proper syntax. If you want to set multiple classes on an html element it should look like:

with all class names inside the same set of double quotes with a space between each. The CSS specificity is controlled by the order of the classes in your CSS file. If your CSS has:

then text inside the div will be red as class-1 is the last declared in the CSS. The order the classes appear in the html is irrelevant.

  1. 1 class-2 {color: blue}
  2. 2 class-3 {color: green}
  3. 3 class-1 {color: red}

Report this snippet  

You need to login to post a comment.