• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

nSiteful Web Builders

Building a Better Web - One Site at a Time.

  • Home
  • About
    • Testimonials
    • Resources
    • Partner With Me
    • Frequently Asked Questions
  • Web Sites
  • Online Marketing
  • WordPress Support
    • Customized WordPress Training
    • 60-for-60 Sessions
  • Web Applications
  • Blog
    • At-A-Glance
    • Blog Articles Grouped by Category
    • Case Studies
    • General
    • Portfolio
    • Reviews
    • Snippets
    • Techniques
    • Projects
  • Contact
    • Purchase Retainer Consulting Hours
    • About Retainer Consulting Hours
    • Book a Meeting with Jeff
    • Tell Me About Your Web Project
    • nSiteful Newsletter Archives
    • nSiteful Rewards
Tables

By Jeff - 11/20/2024
Cats: Techniques · Tags: CSS, Mobile Responsive, Mobile-Friendly

techniques

Responsive Tables with Minimal CSS

On this page...

Toggle
  • Introduction
  • Demo table at viewport width of 800px
  • Demo table at viewport width of 500px
  • HTML of some table rows
  • General CSS for table
  • The CSS for screen width under 500px — the responsive stuff

Last updated March 28th, 2025 at 11:57 pm

Introduction

HTML tables have been around since the beginning of the web. When I started making websites in 1994, HTML tables were our only layout tool. Fast forward 30 years, and tables are still around. They still serve a purpose, but that purpose is no longer webpage layout; thankfully, we have many better layout tools, such as Flexbox and CSS grid.

That said, tables are still one of the best tools HTML offers for presenting structured information in a matrix of rows and columns — that is, except when the user’s device is too small for the content to fit.

This article and screencast will show you how I make HTML tables mobile responsive with just 12 CSS declarations inside a media query.

I welcome your comments, including suggestions for doing this better.

Hat tip to Kevin Powell for his “How to create a responsive HTML table” video from April 2023.

Demo table at viewport width of 800px

Displays as native HTML table above 500px wide viewport

Demo table at viewport width of 500px

Responsive at 500px wide viewport

HTML of some table rows

The use-label class and the data-label attribute value are instrumental in this process.

<tr>
	<td class="event">Lorem, ipsum dolor Lorem ipsum dolor sit amet consectetur..</td>
	<td class="use-label cost" data-label="Cost">$300</td>
	<td class="use-label access" data-label="Access">Public</td>
	<td class="use-label start-date" data-label="Start Date">8/15/2024</td>
	<td class="use-label end-date" data-label="End Date">9/15/2024</td>
</tr>
<tr>
	<td class="event">Lorem ipsum dolor sit amet consectetur adipisicing elit. Quam tenetur at omnis.</td>
	<td class="use-label cost" data-label="Cost">$99</td>
	<td class="use-label access" data-label="Access">Private</td>
	<td class="use-label start-date" data-label="Start Date">8/15/2024</td>
	<td class="use-label end-date" data-label="End Date">9/15/2024</td>
</tr>
<tr>
	<td class="event">Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam et dolorem necessitatibus accusamus laboriosam!.</td>
	<td class="use-label cost" data-label="Cost">$130</td>
	<td class="use-label access" data-label="Access">Public</td>
	<td class="use-label start-date" data-label="Start Date">8/15/2024</td>
	<td class="use-label end-date" data-label="End Date">9/15/2024</td>
</tr>
<tr>
	<td class="event">Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam et dolorem necessitatibus accusamus laboriosam!.</td>
	<td class="use-label cost" data-label="Cost">$45</td>
	<td class="use-label access" data-label="Access">Public</td>
	<td class="use-label start-date" data-label="Start Date">8/15/2024</td>
	<td class="use-label end-date" data-label="End Date">9/15/2024</td>
</tr>

General CSS for table

table {
	margin-inline: auto;
	width: auto;
	border-collapse: collapse;
}
th,
td {
	border: 1px solid #333;
	padding-inline: 0.5rem;
}

The CSS for screen width under 500px — the responsive stuff

Note that only the highlighted lines are required. All others govern optional presentation styles. In other words, only 5 lines of CSS declarations (and some specific HTML markup) are needed to make a table responsive.

@media (max-width: 500px) {
	td,
	tr {
		display: block;
		border: none;
	}
	tr {
		border-bottom: 1px solid #999;
		padding-bottom: 0.5rem;
	}
	thead {
		display: none;
	}
	td.event {
		font-weight: bold;
		margin-block: 1rem 0.5rem;
	}

	td.use-label::before {
		content: attr(data-label) ": ";
		font-style: italic;
		color: darkgreen;
	}
	td.use-label {
		display: grid;
		grid-template-columns: 15ch 1fr;
	}
}

Like what you see? Share with others and join my mailing list. No long-term commitment, unsubscribe any time.

Related Posts

  1. Create Accordions & Toggles in WordPress with HTML and CSS Only
  2. Libra: What Is It?
  3. Display List of Active Plugins in WordPress Dashboard
  4. Everything can be gamed
  5. Side Effects of Rebuilding Web Sites to be Responsive and Mobile-Friendly

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

mailchimp signup

Subscribe to get notified when new articles are published. Unsubscribe any time. No spam. I promise. Check out my newsletter archives.

social

Twitter Facebook LinkedIn

Recent Articles

  • Post-Specific CSS for WordPress October 5, 2026
  • You built an online course, but they haven’t come. September 16, 2026
  • Custom MemberPress Pricing Pages December 19, 2025
  • CSS Data Attribute Override December 11, 2025
  • MemberPress Rules Using Custom Taxonomies and Custom Roles December 10, 2025

Filter By Category/Tag

Categories

  • Case Studies (8)
  • For Staff (1)
  • General (73)
  • Portfolio (7)
  • Reviews (14)
  • Snippets (24)
  • Techniques (52)

Popular Tags

Advanced Custom Fields Blogging Child Themes Content Marketing CSS Customer Service Custom Fields Custom Post Types Diagnostics Domain Names Facebook FooGallery Genesis Hosting HTML Images iPhone Libra Live Chat Marketing Media MemberPress MemberPress Courses Membership Sites Mobile-Friendly MySQL Photo Gallery php Pinterest Plugins Post Formats Pricing Project Management SEBA SEO Seth Godin Shortcodes Social Networking Surveys Taxonomies Twitter Video Web design Web forms WordPress

Footer

Background

Web Sites | WordPress Support | Web Applications.

Formally trained in liberal arts and education (I have a B.A. in Government from Harvard and studied Secondary Education at Rutgers Graduate School), I have honed my skills in the communication arts and sciences as a teacher, trainer, instructional designer, writer, photographer, calligrapher, helpdesk manager, database programmer, and multimedia developer.

(I've also been a group counselor, waiter, bartender, bicycle messenger boy, computer salesman, carpenter's helper, financial analyst, and school board president.)

Tech

Systems since 1983.
Web sites since 1994.
PHP since 2001.
WordPress since 2007.

Contact

Book Meeting
770-772-5134
Email Jeff
Send Money
All Ways

Copyright 2026, nSiteful Web Builders, Inc.

Cookies Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}
https://iframe.mediadelivery.net/embed/392008/42d18bc1-2adc-4741-b733-053d08d09c32
https://vz-000c5976-3ab.b-cdn.net/42d18bc1-2adc-4741-b733-053d08d09c32/play_720p.mp4

Receive occasional emails from Jeff