diff --git a/includes/views-view-matrix.tpl.php b/includes/views-view-matrix.tpl.php
index 001c0f8..60bfa73 100644
--- a/includes/views-view-matrix.tpl.php
+++ b/includes/views-view-matrix.tpl.php
@@ -18,7 +18,7 @@
   <thead>
     <tr>
       <?php foreach ($header as $col => $col_header): ?>
-        <th class="views-matrix-col-header <?php print (!$col) ? 'views-matrix-col-first' : ''?>"><?php print $col_header; ?></th>
+        <th <?php print drupal_attributes($col_header['attributes']); ?>><?php print $col_header['data']; ?></th>
       <?php endforeach; ?>
     </tr>
   </thead>
diff --git a/includes/views_matrix.theme.inc b/includes/views_matrix.theme.inc
index e82aa28..8fd0a5b 100644
--- a/includes/views_matrix.theme.inc
+++ b/includes/views_matrix.theme.inc
@@ -89,7 +89,7 @@ function template_preprocess_views_view_matrix(&$vars) {
       $row_header[$index] = array(
         'data' => $renders[$index][$options['yconfig']['field']],
         'attributes' => array(
-          'class' => array('views-matrix-row-header'),
+          'class' => array_merge(array('views-matrix-row-header'), $handler->headerClasses('y', $index)),
         ),
       );
       $rows[$index] = $yvalue;
@@ -118,11 +118,16 @@ function template_preprocess_views_view_matrix(&$vars) {
   // Create the header and rows arrays for theme_table(), populating the header
   // and row header cells, and padding out the table with empty cells.
   $vars['header'] = array();
-  $vars['header'][] = '';
+  $vars['header'][] = array('data' => '', 'attributes' => array('class' => array('views-matrix-col-header', 'views-matrix-col-first')));
   // Use the rendered column array, as it is sorted.
-  foreach (array_keys($columns_renders) as $xindex) {
+  foreach ($columns_renders as $xindex => $col_render) {
     // Place the rendered field in the table header.
-    $vars['header'][] = $renders[$xindex][$options['xconfig']['field']];
+    $vars['header'][] = array(
+      'data' => $col_render,
+      'attributes' => array(
+        'class' => array_merge(array('views-matrix-col-header'), $handler->headerClasses('x', $xindex)),
+      ),
+    );
   }
 
   // Fill up the table with the first column of each row from the row header,
diff --git a/includes/views_matrix_plugin_style_matrix.inc b/includes/views_matrix_plugin_style_matrix.inc
index 0d2849e..90ee144 100644
--- a/includes/views_matrix_plugin_style_matrix.inc
+++ b/includes/views_matrix_plugin_style_matrix.inc
@@ -17,10 +17,12 @@ class views_matrix_plugin_style_matrix extends views_plugin_style {
     $options['xconfig'] = array('default' => array(
       'field' => '',
       'sort' => '',
+      'class' => '',
     ));
     $options['yconfig'] = array('default' => array(
       'field' => '',
       'sort' => '',
+      'class' => '',
     ));
 
     return $options;
@@ -62,6 +64,13 @@ class views_matrix_plugin_style_matrix extends views_plugin_style {
       '#default_value' => $this->options['xconfig']['sort'],
     );
 
+    $form['xconfig']['class'] = array(
+      '#type' => 'textfield',
+      '#title' => t('CSS class'),
+      '#description' => t('You may use token substitutions from the rewriting section in this class.'),
+      '#default_value' => $this->options['xconfig']['class']
+    );
+
     $form['yconfig'] = array(
       '#type' => 'fieldset',
       '#title' => t('Row header'),
@@ -85,6 +94,13 @@ class views_matrix_plugin_style_matrix extends views_plugin_style {
       '#options' => array('asc' => t('Ascending'), 'dsc' => t('Descending')),
       '#default_value' => $this->options['yconfig']['sort'],
     );
+
+    $form['yconfig']['class'] = array(
+      '#type' => 'textfield',
+      '#title' => t('CSS class'),
+      '#description' => t('You may use token substitutions from the rewriting section in this class.'),
+      '#default_value' => $this->options['yconfig']['class']
+    );
   }
 
   /**
@@ -111,4 +127,18 @@ class views_matrix_plugin_style_matrix extends views_plugin_style {
 
     return $errors;
   }
+
+  /**
+   * Return the class of the field headers.
+   */
+  function headerClasses($dimension, $row_index = NULL) {
+    $field_handler = @$this->view->field[$this->options["{$dimension}config"]['field']];
+    if (empty($field_handler)) return array();
+    $classes = explode(' ', $this->options["{$dimension}config"]['class']);
+    foreach ($classes as &$class) {
+      $class = $field_handler->tokenize_value($class, $row_index);
+      $class = views_clean_css_identifier($class);
+    }
+    return $classes;
+  }
 }
