Title: Adding class to table name and description
Last modified: August 21, 2016

---

# Adding class to table name and description

 *  Resolved [myironlung3](https://wordpress.org/support/users/myironlung3/)
 * (@myironlung3)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-class-to-table-name-and-description/)
 * Hello,
 * This is a great plugin. One problem I have is that there is no container that
   wraps the table name, description, and table. For example something like this
   would be ideal:
 * <div class=”tablepress-container”>
    <h2 class=”tablepress-table-name”></h2> <
   span class=”tablepress-table-description”></span> <table class=”tablepress”></
   table> </div>
 * If the custom CSS class option is added to the “tablepress-container” instead
   of the <table>, we can do things like set a fix width for the entire table, float,
   position as necessary. Currently the custom CSS classes are only added to the
   <table> which limits the ability to control the table display if there is a table
   name or description displayed.
 * Is there any consideration to make this change in a future release or is there
   a way for me to add the custom CSS class to the table name and description?
 * The specific problem I am having is when I make a table with custom CSS class
   =”small” and make it 300px wide, the table name and description are still 100%
   width and I can’t float or position all the elements together.
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-class-to-table-name-and-description/#post-4634643)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * That’s an interesting topic. You are right, the “Extra CSS class” is added to
   the table only at this time. Changing that to a wrapping `<div>` container for
   everybody is not really necessary in my opinion, as there are very few use cases
   that actually require it.
    Instead, here are some ideas for you: Why don’t you
   add the wrapper yourself, by putting a `<div>` around your Shortcode, like
 *     ```
       <div class="tablepress-container small">
       [table id=123 /]
       </div>
       ```
   
 * If you prefer an automatic solution, you could use the `tablepress_table_output`
   filter hook to add the wrapper:
 *     ```
       add_filter( 'tablepress_table_output', 'tp_add_div_wrapper', 10, 3 );
       function tp_add_div_wrapper( $output, $table, $render_options ) {
         $output = "<div class='tablepress-wrapper {$render_options['extra_css_classes']}'>\n{$output}\n</div>";
         return $output;
       }
       ```
   
 * That code would have to be placed in your theme’s “functions.php” file or into
   a custom small new plugin.
    It even add the “Extra CSS classes” to the wrapper
   🙂
 * Regards,
    Tobias
 *  Thread Starter [myironlung3](https://wordpress.org/support/users/myironlung3/)
 * (@myironlung3)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-class-to-table-name-and-description/#post-4634727)
 * That filter is awesome! Solved the problem perfectly. Thank you.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-class-to-table-name-and-description/#post-4634734)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](http://wordpress.org/support/view/plugin-reviews/tablepress)
   here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding class to table name and description’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/adding-class-to-table-name-and-description/#post-4634734)
 * Status: resolved