views:

40

answers:

2

I have a table like this:

<table>
  <tr>
    <th>Header</th>
    <td>Content</td>
  </tr>
  <tr>
    <th>Header</th>
    <td>Content</td>
  </tr>
</table>

How can I make the header actually float above the content cell without putting everything on a separate row? For instance:

Header
Content

Header
Content
+2  A: 

Try this in your css:

td,th{display:block;}

edl
This only works if you've only got one column...
Matthew Smith
+3  A: 

You don't give a lot of information, but you might be better off using a Definition List, rather than a mangled table, depending on the semantics:

<dl>
    <dt>Header</dt>
    <dd>Content</dd>

    <dt>Header</dt>
    <dd>Content</dd>
</dl>

This will get you output that looks something like this:

Header
   Content

Header
   Content

It's then trivial to style via css, as the Headers are dt's and the Contents are dd's:

dt { font-weight: bold; font-size: 200%; }
dd { color: #999; }

See also:

dflock