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:
- In your Shopify admin, go to Online Store > Themes.
- Duplicate your theme first! This is a crucial step before making any code changes, so you have a backup.
- Click Actions > Edit code for your duplicated theme.
- Navigate to the specific section that contains your comparison table (e.g., a custom section you've added).
- Within that section's settings panel, look for a Custom CSS box at the bottom.
- 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:
- In your Shopify admin, go to Online Store > Themes.
- Again, duplicate your theme first!
- Click Actions > Edit code for your duplicated theme.
- Find the
theme.liquidfile in the left sidebar under "Layout." - Add the following code at the bottom of the file, just above the

