Responsive HTML table

Hi there. Not that long ago @PaulOB gave a solution for a responsive HTML table and I’ll be jiggered if I can find the thread. Can anyone help please?

He has an example here, but I think there was another one where he has an on-line working example of it.

Thanks, Sam. I will have a go with this. I think there was a more recent one with a lot more mark-up.

Not sure if either of these might be what you had in mind. Paul’s, but not that recent:

More recent, but not Paul:


Try this:

7-Columns and Google Mobile Friendly but - #2 by PaulOB

1 Like

Found his pen:-

1 Like

Thanks a lot TB, Ralph and Sam. That is the one I was looking for. Having looked at it and my table I’m not sure my table would work with it as I have column and row headers

I’m thinking I might cheat and hide two of the years’ data. (Oh, did I really say that!)

Paul’s example worked fine on my seven daily columns and it passed the acid test:

Google Mobile Friendly Test

My problem (I think) is that the first column is a row header. I’m not sure how this would work. It seems the single column end-result would look rather odd.

Maybe it could be modified, with a class on the first header column, to make a 2 column table?
Though I couldn’t say how off the top of my head.

Works well for me with a simple tweak.

<meta charset="utf-8">
<title>Untitled Document</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
.mytable {
	margin:0 auto;
.mytable td, .mytable th {
	border:1px solid #000;
p {
	margin:0 0 1em
.mytable tbody th {
@media screen and (max-width:601px) { {
} thead {
}, tr{display:block;width:100%} td, tbody th {
	float:left;/* ie9 and under hack */
	padding:10px 5px;
} tbody th{text-align:center;} tbody, tr {
.mobile-optimised td:before {
	content:attr(data-th) ' :';
.mobile-optimised tbody td:last-child {
	border-bottom:1px solid #000;

<table class="mytable mobile-optimised datatable">
				<tr class="head">
						<th scope="col">2011/12</th>
						<th scope="col">2012/13</th>
						<th scope="col">2013/14</th>
						<th scope="col">2014/15</th>
						<th scope="row">Balance brought forward</th>
						<td data-th="2011/12">5,903</td>
						<td data-th="2011/13">5,674</td>
						<td data-th="2011/14">5,741</td>
						<td data-th="2011/15">7,615</td>
						<th scope="row">+ Annual precept</th>
						<td data-th="2011/12">6,700</td>
						<td data-th="2011/13">7,400</td>
						<td data-th="2011/14">7,025</td>
						<td data-th="2011/15">7,461</td>
						<th scope="row">+ Total other receipts</th>
						<td data-th="2011/12">4,929</td>
						<td data-th="2011/13">8,689</td>
						<td data-th="2011/14">7,622</td>
						<td data-th="2011/15">9,216</td>
						<th scope="row">&#8211; Staff costs</th>
						<td data-th="2011/12">2,261</td>
						<td data-th="2011/13">2,882</td>
						<td data-th="2011/14">3,066</td>
						<td data-th="2011/15">2,894</td>
						<th scope="row">&#8211; Loan interest / capital repayments</th>
						<td data-th="2011/12">0</td>
						<td data-th="2011/13">0</td>
						<td data-th="2011/14">0</td>
						<td data-th="2011/15">0</td>
						<th scope="row">&#8211; Total other payments</th>
						<td data-th="2011/12">9,597</td>
						<td data-th="2011/13">13,140</td>
						<td data-th="2011/14">9,707</td>
						<td data-th="2011/15">15,888</td>
						<th scope="row">= Balance carried forward</th>
						<td data-th="2011/12">5,674</td>
						<td data-th="2011/13">5,741</td>
						<td data-th="2011/14">7,615</td>
						<td data-th="2011/15">5,510</td>
						<th scope="row">Total cash and investments</th>
						<td data-th="2011/12">5,674</td>
						<td data-th="2011/13">5,741</td>
						<td data-th="2011/14">7,615</td>
						<td data-th="2011/15">5,510</td>
						<th scope="row">Total fixed assets and long term assets</th>
						<td data-th="2011/12">228,926</td>
						<td data-th="2011/13">233,245</td>
						<td data-th="2011/14">233,245</td>
						<td data-th="2011/15">233,245</td>
						<th scope="row">Total borrowings</th>
						<td data-th="2011/12">0</td>
						<td data-th="2011/13">0</td>
						<td data-th="2011/14">0</td>
						<td data-th="2011/15">0</td>

I prefer the mobile version to the dektop.:slight_smile:


Thanks Paul. I might have known I wouldn’t be allowed to cheat! :slight_smile: Many thanks

Just one thing - is there any way to get a border-top for the whole table? I’ve tried various things and either get nothing or a double border all but the top and bottom “rows”.

Like this?

That’s it! Strange it didn’t work for me before. Cheers Sam

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.