Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.385 diff -u -p -r1.385 theme.inc --- includes/theme.inc 25 Sep 2007 12:43:18 -0000 1.385 +++ includes/theme.inc 4 Oct 2007 13:10:17 -0000 @@ -1282,20 +1282,23 @@ function theme_table($header, $rows, $at drupal_add_js('misc/tableheader.js'); $ts = tablesort_init($header); - $output .= ' '; + // HTML requires that the thead tag has tr tags in it follwed by tbody + // tags. Using ternary operator to check and see if we have any rows. + $output .= (count($rows) ? ' ' : ' '); foreach ($header as $cell) { $cell = tablesort_header($cell, $header, $ts); $output .= _theme_table_cell($cell, TRUE); } - $output .= " \n"; + // Using ternary operator to close the tags based on whether or not there are rows + $output .= (count($rows) ? " \n" : "\n"); } else { $ts = array(); } // Format the table rows: - $output .= "\n"; if (count($rows)) { + $output .= "\n"; $flip = array('even' => 'odd', 'odd' => 'even'); $class = 'even'; foreach ($rows as $number => $row) { @@ -1335,9 +1338,10 @@ function theme_table($header, $rows, $at $output .= " \n"; } } + $output .= "\n"; } - $output .= "\n"; + $output .= "\n"; return $output; }