tags:

views:

128

answers:

1

instead of the usual vertical table data layout something like this:

alt text

i'd like to display it like this in css:

alt text

any ideas?

my php/html code:

<div class="center_div">
<table>
<tr>
<th>Author</th>
<th>Quotes</th>
<th>Arabic</th>
<th>Reference</th>
</tr>
    <?php while ($row= mysql_fetch_array($result)) { ?>
        <tr>
            <td width="150"><?php h($row['vAuthor']) ?></td>
            <td><?php h($row['cQuotes']) ?></td>
            <td><?php h($row['cArabic']) ?></td>
            <td><?php h($row['vReference']) ?></td>
        </tr>
    <?php } ?>
</table>
</div></div>
+2  A: 

A table has to be a table, therefore you describe it semantically that way.
A table consists of table rows which contain table data. Changing table data to table rows just by using CSS would just make your semantic worthless. Table rows are meant to be table rows so you should rather restructure your HTML instead of re-arranging anything with CSS.

If you want to achieve a horizontal layout as you depicted it, I recommend using div-Containers instead of tables.

Remember: Tables are used to display tabular data. They are not really meant to be used as a foundation for your layout.

Ham
@Ham, thanks for your comment. i am using tables to display tabular data and i have seen websites displaying tabular data with a horizontal "table" layout than a vertical one. therefore, wondering if i could do the same.
fuz3d
So why don't you just restructure your table? Instead of putting multiple `<td>` s into a `<tr>` just write several `<tr>`s containing one `<td>` each.That will give you what you need, won't it?
Ham
thanks for the pointer, i found what i was looking for: http://icant.co.uk/csstablegallery/index.php?css=60#r60
fuz3d