Forum Moderators: not2easy

Message Too Old, No Replies

Aligning a table with text?

How to align the content of a table with surrounding text

         

johann_p

7:11 am on Jun 7, 2007 (gmt 0)

10+ Year Member



I would like to align a table that has "display: inline;" with the surrounding text, so that the text inside of the table is at the same height as the text outside of the table. Is this possible?

Currently, the text inside the table is always a bit higher than the text outside. The best I achieved is to align the lower edge of the table with the baseline of the surrounding text using "vertical-align: baseline;" for the table. But the text inside the table (there is only one row) is still seperated from the bottom of the table -- how can I get rid of this too?

Robin_reala

1:01 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld johann_p! (are you johann_p from mozillazine?)

To align a table inline you'd use

display:inline-table
- the problem with that is that neither Firefox nor IE support this (although Opera and Safari do). By applying
display:inline
to the table you're saying it should become an inline element (like a
<span>
) and apply all the normal inline rules, effectively abandoning its table behaviours (and gaining ones like the ability to be split over multiple lines).

Can I ask what situation you're using this in? If there's only one row then you might be able to achieve the same visual effect with a more amenable (and semantic) bit of HTML.

johann_p

7:23 pm on Jun 7, 2007 (gmt 0)

10+ Year Member




Can I ask what situation you're using this in? If there's only one row then you might be able to achieve the same visual effect with a more amenable (and semantic) bit of HTML.

There is only one shown row, though there are two logical rows in the table, like so:
<tr><td></td><td rowspan="2" valign="bottom">stuff1</td><td></td></tr>
<tr><td>stuff2</td><td>stuff3</td></tr>

This is some crazy way to avoid recognition of the term stuff2 stuff1 stuff3 within text (not my idea but I have to deal with it).
Until now this was only used in separate lines, but I would like to use this within normal text.

In any case, pity to see that there is yet another css feature that is not supported by all important browsers. :(