This is pretty gross.  Could you not build this from code?  Put the class names in an array of arrays (rows of keys), and then use some for loops to build up a string that produces this html.