An HTML table is used for storing data or information. A table is often a key component in webpage building so it is important that we know how to create responsive tables in the era of responsive web design.
There are several different types of HTML tables and today we are going to take a closer look at them to better understand their purpose and creation of the responsive tables with CSS & HTML or WordPress.
Table of contents
Responsive Design and responsive tables
If we want to understand responsive tables better, first we need to know what it means when we say that a design is responsive.
Responsive design is the design that is adjustable to the screens of different sizes. When we talk about an HTML image or table, it’s all about what happens when the screen is narrower than the minimum width of a data table.
Responsive Tables as a Part of a Responsive Design
Making tables responsive has been quite a challenge since the introduction of responsive web design.
Data tables are often quite wide and a single row of data often needs to be kept together if we want it to actually make sense. Of course, tables can flex in width, but is that really a solution? Well, it can be until the point when they start wrapping cells’ content in a way we don’t want them to. There is also a point where they simply can’t go any narrower.
Luckily, there are 3 patterns that can help us solve this problem:
The Horizontal Overflow
The horizontal overflow table in HTML can be easily seen whole by simply scrolling right and left. The first field is usually fixed and the others become visible as the user scrolls through the content.
There is one downside, however. The user might not know or notice that the table is scrollable. If that happens, there is a chance they will miss most of the table. To avoid the possibility of the user not seeing the most important content, the key fields should be in the first 3 columns.
The Transitional Tables
A transitional CSS table is a good solution if you want to avoid scrolling that is the necessary part of viewing the horizontal overflow tables.
What happens with this table is that the field titles are formatted at lower CSS breakpoints to a row format instead of a column structure.
Unfortunately, there is also a downside. A transitional table CSS diminishes scanability and field comparison.
The Priority Tables
The priority tables simply hide fields on lower screen sizes. The tables formatted like this usually look beautiful but the problems occur if the omitted fields were, in fact, the most important ones.
Responsive Table Approaches
There are several ways to make responsive tables.
- Squash–you can squash table HTML horizontally by moving the HTML table border if there isn’t much content in the columns. By doing this, you can avoid changing the entire layout of your table
- Vertical scroll–if you want to avoid changing the content and/or the layout of your table, by all means, the users can scroll to the left and right to see the full table
- Collapse by rows – you can turn your table into several smaller tables by splitting each row into its own single column
Things to Avoid when Building a Responsive Table
People have tried many different methods of building responsive tables and here are some that are not particularly effective. You should probably avoid them altogether.
- Keeping table markup and switching to display:flex for vertically aligned table content.
NOTE: If all of the above sounds too complicated to even try – don’t get discouraged. There are simpler ways to create responsive tables. You can visit w3schools.com for more useful tips (w3schools HTML offers a variety of explanations HTML help for the website builders). So let’s take a look at some of the tools that you might find useful.
How to create responsive tables
WpDataTables works with any WordPress Theme. It is one of the most popular WordPress Excel-style table generators. It comes in two versions: Lite and Premium.
One of its benefits is the quick and easy setup process. It’s user-friendly, so previous coding experience isn’t necessary to use this plugin.
It allows users to create dynamic and customizable tables. It can merge cells, add star ratings, and style each individual cell.
Other functions enable the adding and removing of columns and rows, and resizing them. The formatting customization includes changing the color, inserting a company logo, and more.
The Undo/Redo feature is also very useful when creating a personalized table.
The generator offers custom links and custom HTML. It supports Excel, CSV, JSON, XML, and serialized PHP arrays.
The Lite version comes with documentation and tutorials. But there is a maximum limit of 150 rows per table. It also does not allow users to create a table manually.
The Premium version offers additional features that enable users to design highly responsive tables. These features include multiple database support and advanced filters.
It is worth trying the free plugin with all its features first. If it’s discovered that the advanced functions are necessary, then opt for the Premium version.
The team and support are professional.
- Responsive tables by default
- Flexible and customizable
- Excel-like interface
- Advanced filtering
- Inline table editing
- Visitors filter tables on a per-column basis
- Visitors can edit their own rows
- Conditional formatting, formulas, and more
- Calculation functions
A responsive table plugin built on jQuery and made for Bootstrap.
Responsive jQuery tables
A simple lightweight jQuery responsive table library. A library to setup tables for a basic responsive table structure.
Tested on Win8.1 with browsers: Chrome 37, Firefox 32, Opera 25, IE 11, Safari 5.1.7 You can use this table in Bootstrap (v3) projects. Material Design Responsive Table CSS-style will override basic bootstrap style.
Responsive table with just CSS
This is a relatively well-known pattern for responsive tables, but it’s worthwhile to give a reminder or FYI to the new folks.
Really Responsive Tables using CSS Flexbox – part 4. A complex example with lots of different kinds of fields, and a very custom wrapping logic. This is part of the Really Responsive Tables pen collection.
Changes table layout to work in mobile size screens. This is adapted from Geoff Yuen’s Responsive Table design.
Responsive Tables with Flexbox
This Pen is a fork of Davide Rizzo’s Pen Responsive Tables (By columns).
Ending thoughts on how to create responsive tables
In the era of responsive design, we have to make sure that our tables behave responsively. Luckily, it is not as difficult as it may sound.
Adjusting the CSS table border and creating responsive CSS tables or HTML images and tables can give you a hard time if you don’t know what you’re doing. However, with the help of a few useful plugins and extensions, building responsive tables should be easier than ever.
wpDataTables can be the perfect solution. The best-selling plugin is already a choice of more than 40,000+ businesses online. wpDataTables can handle any complex data, be it financial, scientific, statistical, commercial, or any other information – you will get the pixel-perfect table every time. Additionally, you can check a list of 10 Best Responsive Table Plugins For WordPress, a comparison made by our friends at wp Leaders.
It is also important to check how these tables are rendering in various browsers & OS, for the same you can perform responsive testing and make sure your designs are responsive and rendering well.
If you enjoyed reading this article on responsive tables with CSS, you should check out this one about Bootstrap tables.