Chapter 20: Responsive Tables

Priority Column Hiding

Progressive column disclosure, responsive priority utility systems, interactive expandable row drawers, and accessibility-compliant data triage.

LEARNING OBJECTIVES
  • Implement a tier-based priority column system using responsive CSS media queries.
  • Understand progressive disclosure principles to triage high-priority vs secondary data attributes.
  • Build interactive expandable accordion row drawers (<details> / <summary> and expandable child <tr> rows) to restore access to hidden columns on mobile.
  • Maintain screen reader comprehension and avoid orphaned tabular data during column suppression.
🎬 INTERACTIVE VISUAL PIPELINE Core Architecture Simulation
🌐
1. Input
Directives & Tags
⚙️
2. Parse
Tokenizer & AST
🌳
3. Layout
Box Model & Flow
🎨
4. Render
GPU Paint & Composite
PHASE 1: INPUT & DIRECTIVES
Browser receives declarative markup stream, parsing tag tokens and initializing component state.

📖 The Mental Model & Story (Intuitive Foundation)

Imagine boarding a commercial airplane. When looking at the full flight manifest at the gate terminal, the flight coordinator sees 15 dense data fields per passenger: Seat Number, Full Legal Name, Frequent Flyer Tier, Ticket Class, Passport Number, Nationality, Luggage Tag Count, Meal Preference, Special Assistance, Booking Reference, Check-in Timestamp, Security Clearance, Connecting Flight, Gate Number, and Boarding Group.

Full Gate Manifest (15 Columns on 32" Desktop):
+------+---------------+-----------+----------+---------------+-----------------+-------------+
| Seat | Passenger     | Tier      | Class    | Passport      | Luggage Count   | Meal        | ...
+------+---------------+-----------+----------+---------------+-----------------+-------------+
| 14A  | Sarah Jenkins | Diamond   | First    | US-89421094   | 2 checked       | Vegan       | ...
+------+---------------+-----------+----------+---------------+-----------------+-------------+

Flight Attendant Mobile Handheld (Triage Priority View):
+------+---------------+-----------+--------+
| Seat | Passenger     | Tier      | [ More ]
+------+---------------+-----------+--------+
| 14A  | Sarah Jenkins | Diamond   |   [v]  | -> Tapping expands drawer showing Passport, Luggage, Meal
+------+---------------+-----------+--------+

When a flight attendant walks down the narrow airplane aisle holding a compact mobile handheld device, they only need Seat Number, Name, and Status at a glance to guide passengers to their seats. If a passenger asks about their meal or luggage, the flight attendant taps an expand button on that specific row to slide open a detailed drawer containing the lower-priority attributes.

In web engineering, Priority Column Hiding applies this triage principle: display essential primary columns across all screen widths, hide secondary/tertiary columns at narrow breakpoints, and provide an interactive mechanism to inspect the hidden details on demand.


Technical Deep Dive & Specifications

The Priority Tier Matrix

To systematically control column visibility across viewports, we establish a standardized Priority Classification Hierarchy:

+-----------------------------------------------------------------------------------------------+
| Priority Tier | Classification  | Visible Breakpoint       | Example Fields                   |
+-----------------------------------------------------------------------------------------------+
| Priority 1    | Essential (Core)| All Viewports (>= 0px)   | Entity Name, ID, Primary Status  |
| Priority 2    | Important       | Tablet & Desktop (>=640px)| Date, Category, Primary Metric   |
| Priority 3    | Secondary       | Desktop Only (>=1024px)  | Subscriptions, Tags, Region      |
| Priority 4    | Tertiary / Gran | Widescreen (>=1280px)    | Timestamps, Hash IDs, Audit Logs |
+-----------------------------------------------------------------------------------------------+

CSS Utility Class Architecture

We map these priority tiers directly to reusable CSS classes:

/* Base: Mobile First (Hide everything except Priority 1) */
.col-p2,
.col-p3,
.col-p4 {
  display: none;
}

/* Tablet (>= 640px): Reveal Priority 2 */
@media (min-width: 640px) {
  .col-p2 {
    display: table-cell;
  }
}

/* Desktop (>= 1024px): Reveal Priority 3 */
@media (min-width: 1024px) {
  .col-p3 {
    display: table-cell;
  }
}

/* Widescreen (>= 1280px): Reveal Priority 4 */
@media (min-width: 1280px) {
  .col-p4 {
    display: table-cell;
  }
}
Breakpoint Behavior Breakdown:
Width < 640px:   [ P1 (Name) ]                                   [ Action Drawer (v) ]
Width 640-1023:  [ P1 (Name) ] [ P2 (Category) ] [ P2 (Price) ]   [ Action Drawer (v) ]
Width >= 1024px: [ P1 (Name) ] [ P2 (Category) ] [ P2 (Price) ] [ P3 (SKU) ] [ P3 (Stock) ]

The Progressive Disclosure Pattern (Expandable Child Rows)

Hiding data entirely without a fallback penalizes mobile users who require full access. The industry-standard solution is an Expandable Detail Drawer:

  1. On desktop, the toggle button column is hidden (display: none), and all data columns are visible in the main row.
  2. On mobile, secondary columns are hidden from the main row, and a toggle button column is displayed.
  3. Clicking the toggle button expands an auxiliary <tr class="detail-row"> containing a full list of the hidden data attributes.
Desktop Layout:
+--------------------------------------------------------------------------+
| Order ID  | Customer     | Product       | Date       | Amount | Status  |
| #1001     | Alice Cooper | Cloud Server  | 2026-08-20 | $499   | Active  |
+--------------------------------------------------------------------------+

Mobile Layout (Collapsed):
+--------------------------------------------------------------------------+
| [>] #1001     | Alice Cooper                   | $499                    |
+--------------------------------------------------------------------------+

Mobile Layout (Expanded Detail Drawer):
+--------------------------------------------------------------------------+
| [v] #1001     | Alice Cooper                   | $499                    |
| +----------------------------------------------------------------------+ |
| | Product: Cloud Server Dedicated | Date: 2026-08-20 | Status: Active   | |
| +----------------------------------------------------------------------+ |
+--------------------------------------------------------------------------+

💻 Interactive Code Playground

Starter Code

Line-by-Line Code Breakdown

  • Lines 73–92: Priority utility media queries. Classes .p-priority-2 and .p-priority-3 remain display: none on mobile screens and activate into display: table-cell as the viewport reaches tablet ($640\text{px}$) and desktop ($1024\text{px}$) thresholds.
  • Lines 93–99: When the screen is wider than $1024\text{px}$, the toggle button column (.col-toggle) is suppressed (display: none) because all columns fit comfortably in standard horizontal layout.
  • Lines 123–128: The button features aria-expanded="false" and aria-controls="details-101", establishing an explicit relationship for screen reader software between the trigger and the collapsible detail drawer.
  • Lines 135–150: The detail row uses <td colspan="7"> spanning the entire width of the table. Inside, a CSS Grid .detail-container cleanly arranges key-value cards.

Expected Browser Render Output

  • Mobile Viewport (375px): Shows only [▶], Order ID, Customer, and Total. Tapping the [▶] flips the icon to [▼] and slides open a grey drawer displaying Product Tier, Date Placed, and Payment Method.
  • Tablet Viewport (768px): Automatically reveals Product Tier in the main table row.
  • Desktop Viewport (1200px): The [▶] expand button disappears entirely; all 6 data columns are cleanly visible in a single horizontal row.

SYS: ACTIVE
HULL: 98%
CORE: STABLE
NET: ONLINE
HTML STARSHIP CODE TERMINAL playground.html
LIVE RENDER & DIAGNOSTICS CORE TEMP: 45°C
INSPECTING DOM: VALID
TAGS: SCANNING...

🏋️ Hands-On Exercise

🎯 The Challenge: Add Priority Column Tiers to a Server Health Table

Instructions:

  1. Assign priority classes to the table columns:
    • Server Name & Status: Priority 1 (Always visible).
    • CPU Usage & Memory: Priority 2 (Visible $\ge 600\text{px}$).
    • Disk IOPS & Uptime: Priority 3 (Visible $\ge 900\text{px}$).
  2. Add the corresponding CSS classes and media queries so the table degrades cleanly without horizontal overflow.

🏁 Starter Code Sandbox

SYS: ACTIVE
HULL: 98%
CORE: STABLE
NET: ONLINE
STARTER CODE SANDBOX exercise.html
LIVE RENDER & DIAGNOSTICS CORE TEMP: 45°C
INSPECTING DOM: VALID
TAGS: SCANNING...

⚠️ Common Pitfalls

  1. Applying priority classes to <td> but forgetting <th>: If you hide a <td> in <tbody> without hiding the corresponding <th> in <thead>, the header row will have more columns than the data rows, shifting all cell data out of alignment!
  2. Neglecting colspan on expanded drawer cells: When inserting a detail drawer <tr class="detail-row">, always set <td colspan="..."> equal to the maximum possible number of columns, otherwise the drawer will only fill the first column width.

💡 Pro Tips

  1. Allow User Column Customization: Implement a user-facing "Column Picker" dropdown (<dialog> or popover) that lets power users override automatic priority rules and customize visible columns in their profile settings.
  2. Accessible Live Regions for Expandable Content: If drawer rows contain dynamic or asynchronously fetched data, add aria-live="polite" to the container so screen readers notify users when content finishes loading.

📌 Key Takeaways

  • Priority column hiding uses responsive breakpoints to show critical data on mobile and progressive details on larger displays.
  • Priority classes must be applied symmetrically to both <th> headers and <td> data cells.
  • The progressive disclosure drawer pattern ensures mobile users retain full access to suppressed data via interactive accordion rows.
  • Interactive triggers require aria-expanded and aria-controls to communicate drawer state to assistive software.
  • --
⭐ LEARN: HTML 🌟 ⚔️ QUIZ BATTLE ARENA // ACTIVE
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 1 / 3

What happens if a developer adds a priority hiding class (display: none) to all <td> elements in a column but forgets to add it to the corresponding <th> in <thead>?

Question 1 / 3 Topic: HTML Fundamentals
00:45 REMAINING
XP REWARD
+250 XP
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 2 / 3

Which ARIA attribute should be toggled between "true" and "false" on a button that opens and closes a table row detail drawer?

Question 2 / 3 Topic: HTML Fundamentals
00:45 REMAINING
XP REWARD
+250 XP
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 3 / 3

When displaying a full-width expandable detail drawer inside a <tr>, why must the child <td> have an explicit colspan attribute?

Question 3 / 3 Topic: HTML Fundamentals
00:45 REMAINING
XP REWARD
+250 XP