"Jukka K. Korpela" <jk******@cs.tut.fi> skrev i meddelandet
news:Xn****************************@193.229.0.31.. .
"Joakim Braun" <jo**********@jfbraun.removethis.com> wrote:
say I have a table with two rows of one column each.
Sounds like you want present an image with a caption under it. It's
usually best to start from the original problem, partly because there might be
other approaches. For a review of some basic approaches, see
http://www.cs.tut.fi/~jkorpela/www/captions.html
Well, a table approach _might_ be the practical one, but then you might
not even use CSS at all, right?
How do I get the text of the second row's cell to line-break at the
width of the first row's cell, which is determined by the dimensions of
an <img>?
The simple way is to set a width for the table, equal to the width of the
image plus eventual cellpadding, cellspacing, and borders.
There's a different approach though: make the caption text a <caption>
element, so that the table has a single cell only. Then browsers will in
practice determine the width of the table by the cell's content and adjust
the caption text to that width.
Thanks - the HTML was just a sample, what I'm doing is generating tables
server-side from arbitrary numbers of image files in directories. The
captions, determined from exif comments, go in separate rows because I
wanted them to line up evenly, and the images may have different heights.
But I got the the effect I'm after by setting the CSS width of table to some
miniscule amount, after which the columns are sized (and text wrapped)
according to the maximum image width in that column.
--
Joakim Braun