Title: Setting column width based on content
Last modified: March 27, 2019

---

# Setting column width based on content

 *  Resolved [barrettj12](https://wordpress.org/support/users/barrettj12/)
 * (@barrettj12)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/)
 * Is there any way I can set the width of the column to exactly fit the content
   inside it? I am aware of using the custom CSS to set a column to a fixed width(
   e.g. [https://tablepress.org/faq/column-widths/](https://tablepress.org/faq/column-widths/)),
   but how can one set the width dynamically based on the cell contents?
    -  This topic was modified 7 years, 2 months ago by [barrettj12](https://wordpress.org/support/users/barrettj12/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsetting-column-width-based-on-content%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/#post-11360793)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * The table is actually trying to do that. How exactly would you like the table
   to look on this page, i.e. where do you think that the widths are “wrong”?
 * Regards,
    Tobias
 *  Thread Starter [barrettj12](https://wordpress.org/support/users/barrettj12/)
 * (@barrettj12)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/#post-11372239)
 * Hi Tobias,
 * Currently it looks decent because I have had to manually set the column widths
   using CSS. However, my concern is that this will not scale to different font 
   sizes, different browsers, etc. I have now disabled those CSS options, and you
   can see that most of the columns take up far more width than they need.
 * What I am asking is: can I ensure that a column takes up only the space it needs,
   and no more? E.g. using a CSS option such as `width: fit-content` does not seem
   to work. Also, is it true that TablePress columns don’t support the CSS `min-
   width` parameter?
    -  This reply was modified 7 years, 2 months ago by [barrettj12](https://wordpress.org/support/users/barrettj12/).
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/#post-11372326)
 * Hi,
 * thanks! Now I see what you mean. Please try this CSS:
 *     ```
       .tablepress {
         table-layout: auto;
       }
       ```
   
 * to override a theme CSS setting.
 * I don’t have experience with `width: fit-content;`, but you could definitely 
   try it. Note that tables in HTML are somewhat special, due to their fixed row/
   column structure, so that not all CSS changes are always possible. Something 
   similar might be the case for the `min-width` parameter. TablePress itself does
   not have an influence on this, as this is all regular HTML/CSS behavior for tables
   that comes into play here.
 * Regards,
    Tobias
 *  Thread Starter [barrettj12](https://wordpress.org/support/users/barrettj12/)
 * (@barrettj12)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/#post-11373021)
 * Thanks! That works great. I will note to others that you can also use the option`
   white-space: nowrap` to avoid line breaks in the cell.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/#post-11373299)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
    Yes, preventing
   line breaks like that is also an option, of course!
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](https://wordpress.org/support/plugin/tablepress/reviews/)
   here in the plugin directory. Thanks!

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

The topic ‘Setting column width based on content’ 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/)

## Tags

 * [column](https://wordpress.org/support/topic-tag/column/)
 * [column width](https://wordpress.org/support/topic-tag/column-width/)
 * [css](https://wordpress.org/support/topic-tag/css/)

 * 5 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/setting-column-width-based-on-content/#post-11373299)
 * Status: resolved