Reputation: 13216
I'm currently using a table to design my timetable - but I've heard that its best to stay away from tables in web development because it is rarely advised. Hence, I was wondering if anyone could prescribe a better method of implementing my timetable? I've tried using div's with little success so far.
Here is the code I'm using and a jsfiddle can be found here http://jsfiddle.net/s2ZgT/:
<div id="grid">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr class="gridHeader">
<td> </td>
<td class="underline">09:00</td>
<td class="underline">10:00</td>
<td class="underline">11:00</td>
<td class="underline">12:00</td>
<td class="underline">13:00</td>
<td class="underline">14:00</td>
<td class="underline">15:00</td>
<td class="underline">16:00</td>
<td class="underline">17:00</td>
</tr>
<tr id="mon">
<td class="gridSide">Mon</td>
<td class="box" id="mon1"> </td>
<td class="box" id="mon2"> </td>
<td class="box" id="mon3"> </td>
<td class="box" id="mon4"> </td>
<td class="box" id="mon5"> </td>
<td class="box" id="mon6"> </td>
<td class="box" id="mon7"> </td>
<td class="box" id="mon8"> </td>
<td class="box" id="mon9"> </td>
</tr>
<tr id="tue">
<td class="gridSide">Tue</td>
<td class="box" id="tue1"> </td>
<td class="box" id="tue2"> </td>
<td class="box" id="tue3"> </td>
<td class="box" id="tue4"> </td>
<td class="box" id="tue5"> </td>
<td class="box" id="tue6"> </td>
<td class="box" id="tue7"> </td>
<td class="box" id="tue8"> </td>
<td class="box" id="tue9"> </td>
</tr>
<tr id="wed">
<td class="gridSide">Wed</td>
<td class="box" id="wed1"> </td>
<td class="box" id="wed2"> </td>
<td class="box" id="wed3"> </td>
<td class="box" id="wed4"> </td>
<td class="box" id="wed5"> </td>
<td class="box" id="wed6"> </td>
<td class="box" id="wed7"> </td>
<td class="box" id="wed8"> </td>
<td class="box" id="wed9"> </td>
</tr>
<tr id="thu">
<td class="gridSide">Thu</td>
<td class="box" id="thu1"> </td>
<td class="box" id="thu2"> </td>
<td class="box" id="thu3"> </td>
<td class="box" id="thu4"> </td>
<td class="box" id="thu5"> </td>
<td class="box" id="thu6"> </td>
<td class="box" id="thu7"> </td>
<td class="box" id="thu8"> </td>
<td class="box" id="thu9"> </td>
</tr>
<tr id="fri">
<td class="gridSide">Fri</td>
<td class="box" id="fri1"> </td>
<td class="box" id="fri2"> </td>
<td class="box" id="fri3"> </td>
<td class="box" id="fri4"> </td>
<td class="box" id="fri5"> </td>
<td class="box" id="fri6"> </td>
<td class="box" id="fri7"> </td>
<td class="box" id="fri8"> </td>
<td class="box" id="fri9"> </td>
</tr>
</tbody>
</table>
</div>
Upvotes: 0
Views: 4891
Reputation: 82297
Looks like a table to me. Why make it anything else? There are situations where you want to implement a system of div
and span
in order to display a complex ui or report, but this is not one of them. The table will naturally respond to changes in content and will render in a layout which users are used to. Tables are very common and are easy to read. Even with some fake data this still looks fine. Here is an example of your code with some simple data in it.
Bottom line: Use tables for tabular displays. Use alternatives for complex displays.
Upvotes: 1
Reputation: 449525
The claim that tables are somehow harmful in themselves is a myth. Tables are harmful when misused for layouting purposes. They are still the weapon of choice when displaying tabular data, which yours clearly is.
Upvotes: 11