How to make responsive table

Bishan picture Bishan · Aug 26, 2013 · Viewed 154k times · Source

I have a table to represent some data in my html page. I'm trying to make this table as responsive. How can I do this?

Here is the Demo.

Answer

hitautodestruct picture hitautodestruct · Aug 26, 2013

Basically

A responsive table is simply a 100% width table.

You can just set up your table with this CSS:

.table { width: 100%; }

Demo here

You can use media queries to show/hide/manipulate columns according to the screens dimensions by adding a class (or targeting using nth-child, etc):

@media screen and (max-width: 320px) {
    .hide { display: none; }
}

HTML

<td class="hide">Not important</td>

More advanced solutions

If you have a table with a lot of data and you would like to make it readable on small screen devices there are many other solutions: