473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Line-break in td to match width of image in previous row?

Greetings,

say I have a table with two rows of one column each.

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>?

<table>
<tr><td><img src="someimg.jpg"></td></tr>
<tr><td>Here we have some text that we'd like to have in a column whose
width matches the image's above so that they line up nicely and the columns
don't become unnecessarily wide.</td></tr>
</table>

--
Joakim Braun
Jul 21 '05 #1
2 6917
"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.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #2
"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
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tor Erik Sønvisen | last post by:
Hi How can I read the first line of a file and then delete this line, so that line 2 is line 1 on next read? regards
6
by: mary | last post by:
When we use string line; while (getline(in,line)) { out.write(line.c_str(),line.size()); out.put('\n'); } in.close();
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
3
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. ...
6
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line...
6
by: Jacob Rael | last post by:
Hello, I have a simple script to parse a text file (a visual basic program) and convert key parts to tcl. Since I am only working on specific sections and I need it quick, I decided not to...
13
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
11
by: xdevel | last post by:
Hi, I don't understand option. if I write: #line 100 "file" I change file numeration to start to line 100 but what "file" ? any example?
19
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48...
0
by: iheartvba | last post by:
Hi, I have got a document where there are headings which are always the same, but their sub categories are always different. The Structure is as follows: Line 1: Heading 1 Line 2: Sub Heading...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.