How can I add a CSS class to all the tables? I want to add a table class to all the tables, automatically. How can I achieve this by overriding a theme function?
If your table is rendered using theme('table'), you can preprocess it from your theme function.

function my_theme_preprocess_table(&amp;$variables) {
  $variables['attributes']['class'][] = 'table';
}