WordPress block tables break on mobile. Headers disappear, content gets squished, and users scroll horizontally to read your data. Not ideal.
Most plugins add bloat. You get features you don't need, extra database queries, and another thing to update.
The Solution
This code snippet makes your WordPress block tables responsive automatically. No plugin required.
Here's what happens on mobile:
- Tables stack vertically instead of side-by-side
- Each row becomes its own section
- Column headers appear next to their data
- Colors adapt to your theme (light or dark mode)
How It Works
The snippet has two parts:
CSS (Mobile Styles)
- Triggers at 650px screen width
- Converts table rows and cells to block display
- Hides the original header row
- Shows column labels inline with data
- Uses your theme's color variables for consistency
JavaScript (Dynamic Labels)
- Reads your table headers automatically
- Adds labels to each cell using
data-column-labelattributes - Runs on page load for all block tables
Installation
Option 1: functions.php Copy the code into your child theme's functions.php file.
Option 2: Code Snippets Plugin Install “Fluent Snippets” or “WPCodeBox”, create a new snippet, paste the code, and activate.
Compatibility
Works with:
- WordPress block tables (Gutenberg)
- Bricks Builder
- Core Framework
- Any theme using CSS variables for colors
The code uses Core Framework variables (--color-background, --color-text) with fallbacks for standard themes.
What You Get
Before (Mobile):
- Horizontal scrolling
- Hidden columns
- Cramped content
After (Mobile):
- Clean vertical layout
- All data visible
- Column headers inline
- Theme-matched colors
Code Features
- Inline comments explaining each section
- Non-breaking spaces in labels (proper rendering)
- No external dependencies
Performance
Zero impact on desktop. Mobile gets a small inline CSS block and lightweight JavaScript that runs once on page load. No external files, no HTTP requests.
When to Use This
You have tables in your content and need them mobile-friendly. You don't want a plugin. You're comfortable adding code to your site.
When Not to Use This
You already have a table plugin that handles responsive design. You need advanced features like sorting, filtering, or CSV imports. You want a no-code solution with a visual interface.