Shopify Comparison Tables: How to Fix Text Overflow on Mobile with Custom CSS

Ever poured your heart into creating a beautiful comparison table on your Shopify store, only to cringe when you see it on a phone? Text overflowing, columns stretching, the whole thing looking like a digital train wreck? You're definitely not alone. It's a super common headache, and it came up recently in the Shopify community forums, highlighting a challenge many store owners face: getting column text to fit properly on smaller screens.

JustinasR, a fellow store owner, hit this exact wall. He was trying to get his product comparison table text to fit nicely within columns, especially on mobile, without "messing up the whole table by going outwards." He even shared a preview of his site, https://www.mansome.lt/collections/masineles/products/lowrider-plauku-kirpimo-masinele, and an image illustrating the issue:

The culprit? Often, it's how browsers handle long words or phrases in narrow columns, especially when things switch to a mobile layout. Fixed widths, non-breaking text, and complex grid structures can quickly lead to an unruly display.

Community Solutions: Two Paths to a Tidy Table

Luckily, our incredible community jumped in with some solid advice and code snippets. We saw two main approaches emerge, each with its own strengths for tackling this responsive design challenge.

1. v.marychenka's Robust CSS for Word Integrity

First up, v.marychenka offered a really thoughtful solution that focuses on keeping your words whole, which is often crucial for readability. They explained that each row in the comparison table often acts as its own grid, meaning a long word in one column might only widen that specific column in its row, not the entire table consistently. Their fix aims to align rows better while preventing words from splitting awkwardly.

How to Implement v.marychenka's Solution:

  1. In your Shopify admin, go to Online Store > Themes.
  2. Duplicate your theme first! This is a crucial step before making any code changes, so you have a backup.
  3. Click Actions > Edit code for your duplicated theme.
  4. Navigate to the specific section that contains your comparison table (e.g., a custom section you've added).
  5. Within that section's settings panel, look for a Custom CSS box at the bottom.
  6. Paste the following CSS code into that box:
@media (max-width: 1023px) {
 [class*="comparison-grid-template"] {
 grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(0, 1fr) !important;
 }
 [class*="comparison-item-template"] { min-width: 0; }
 [class*="comparison-item-template"] h3 { overflow-wrap: break-word; }
}

What's great about this is it specifically targets mobile devices (screens up to 1023px), making sure your label column gets a bit more breathing room (1.8fr) while keeping words like "Reguliuojamas" intact using overflow-wrap: break-word. It ensures that on phones, every row, including the header, gets the same wider label column, while desktop remains untouched. This approach is generally cleaner as it's applied directly to the section's custom CSS.

A quick but crucial heads-up: While the community is fantastic, Shopify Support typically won't troubleshoot custom forum code. Also, if you'd tried a theme.liquid snippet before, v.marychenka recommends removing it first to avoid conflicts. And remember to check your table after any theme updates!

2. Moeed's Quick Fix with line-break: anywhere

Then, Moeed came in with another practical approach, emphasizing a quick win using the line-break: anywhere property. This can be super effective for forcing text to wrap exactly where needed, even if it means splitting a word.

How to Implement Moeed's Solution:

  1. In your Shopify admin, go to Online Store > Themes.
  2. Again, duplicate your theme first!
  3. Click Actions > Edit code for your duplicated theme.
  4. Find the theme.liquid file in the left sidebar under "Layout."
  5. Add the following code at the bottom of the file, just above the tag:

This snippet specifically targets a unique class for that comparison table section (.comparison-item-template--20996797333837__ss_comparison_table_6_BetTGm) on screens up to 767px. Moeed even shared a helpful screenshot showing the result:

The line-break: anywhere property is powerful because it tells the browser, "Hey, just break this line wherever you need to, even mid-word, to make it fit." This can be a speedy way to contain text, though you might see words split (like "spe cialiai" or "L ED"), as v.marychenka pointed out as a potential side effect of this specific property.

Which Solution is Right for Your Store?

So, you've got two solid options from the community. If preserving full words is paramount for your product descriptions and you want a more controlled grid adjustment for mobile, v.marychenka's custom CSS approach for the section is likely your best bet. It gives that main label column more space on mobile and wraps words intelligently.

If you need a faster fix and are okay with words potentially splitting to ensure the table simply fits within the column boundaries, Moeed's line-break: anywhere solution in theme.liquid could be a quicker path to a visible fix. Just remember that the specific class name (.comparison-item-template--20996797333837__ss_comparison_table_6_BetTGm) might be unique to your theme instance. You might need to use your browser's developer tools to inspect your page's code and find the exact class for your comparison table section to ensure the code targets the right element.

Regardless of which path you choose, the core takeaway here is the power of custom CSS to fine-tune your Shopify store's responsiveness. These small tweaks can make a huge difference in user experience, especially for mobile shoppers. Always test your changes thoroughly on various devices and screen sizes. A responsive design isn't just about looking good; it's about making sure your customers can easily read your content and make informed decisions, whether they're browsing on a desktop or a phone.

And hey, if you're just starting out or thinking about diving deeper into customizing your store, a robust platform like Shopify makes it possible to tweak these details. It's a fantastic foundation for any e-commerce business, and the community support is truly invaluable. These kinds of discussions are goldmines for practical solutions to real-world store challenges. Keep experimenting, keep learning, and don't hesitate to tap into the collective wisdom of other merchants and developers!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases