Fixing Shopify Comparison Table Text Overflow: A Community-Driven CSS Guide

Hey everyone! As a Shopify expert and community analyst, I often see store owners grappling with similar design challenges. A classic one that recently popped up in the forums, and really resonated with me, was about getting comparison tables to display correctly on mobile devices. It's a common responsive design headache, and I want to share some fantastic insights from a recent thread that offered practical solutions.

JustinasR started the discussion, seeking help with text overflowing in their comparison table, specifically a long word like "Reguliuojamas" that was breaking the layout. They shared a preview from their store and a screenshot:

This issue often stems from how themes handle comparison tables, where each row might be its own grid. A long word in one row can unbalance the entire table, especially on smaller screens.

Two Approaches to Fixing Text Overflow

The community offered two distinct CSS solutions. Let's break them down.

Option 1: Breaking Lines Anywhere (The Quick Fix)

Moeed provided a quick fix using line-break: anywhere !important;. This forces text to break at any point, even mid-word, to fit the column.

Here's a visual of this solution:

While effective, v.marychenka noted it could lead to awkward word breaks like "spe cialiai." Also, the specific class name used here might vary across themes or updates, making it less universally reliable.

Option 2: Keeping Words Whole with overflow-wrap (Recommended)

For a cleaner look, v.marychenka proposed a more robust CSS solution. This method adjusts grid columns and uses overflow-wrap: break-word to keep words intact where possible, only breaking them if absolutely necessary to prevent overflow.

This approach targets general comparison grid elements and applies changes only on smaller screens (max-width: 1023px), leaving your desktop view untouched.

@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; }
}

This code slightly widens the first column on mobile and then uses overflow-wrap: break-word; as a fallback, ensuring a much smoother visual experience.

Step-by-Step Implementation Guide

Before making any code changes, always duplicate your theme! Go to Shopify Admin > Online Store > Themes, click "Actions" on your current theme, then "Duplicate." This creates a safe backup.

Implementing the Recommended Word-Wrapping Solution

  1. From your Shopify Admin, navigate to Online Store > Themes.
  2. On your duplicated theme, click Actions > Edit code.
  3. In the left sidebar, open the Sections folder.
  4. Find the section file for your comparison table (e.g., comparison-table.liquid, main-product.liquid, or a custom section). You might need to search theme files for "comparison-grid-template" to locate it.
  5. Paste the following CSS into the section's custom CSS area or within
    1. Save and test on mobile. Keep in mind that the specific class name might need adjustment for your theme.

    Important Considerations for Custom Code

    A couple of crucial points from the community discussion:

    • Shopify Support: Official Shopify Support doesn't troubleshoot custom code. For issues, rely on developer help or the community forums.
    • Theme Updates: Custom CSS can be affected by theme updates. Always re-check your comparison tables after an update to ensure proper display.

    Getting your responsive design just right can be tricky, but with these community-tested CSS snippets, you're well on your way to a perfectly aligned comparison table on any device. A smooth shopping experience means happy customers, and that's what it's all about. Happy customizing!

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools