By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,529 Members | 1,826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,529 IT Pros & Developers. It's quick & easy.

Prevent word wrap in a table cell

P: n/a
Hi, all! I have a question.

I am designing a listing similar to a phone book in HTML. Each listing has
periods following it, but they must extend to the end of the table cell, and
not wrap.

Is there any way to prevent the text from 1) wrapping within the table cell
and 2) causing the table cell to expand? In other words, the filler periods
must flow past the right boundary of the cell (but not be seen). Similar to:

[Ben's Car Shop.......................] [555-5555]

Any information is appreciated. Thanks!

--
Dave
www.grundage.com
Mar 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 14 Mar 2006 17:39:41 -0600, "Yeah" <ye**@positive.net> wrote:
Is there any way to prevent the text from 1) wrapping within the table cell


Within the <td> itself:
<td style="white-space: nowrap;">foo</td>

In a stylesheet, something like:

table td {white-space: nowrap;}

The above would apply to all <td>s.

Ian
--
http://sundry.ws/
Mar 15 '06 #2

P: n/a
"Yeah" <ye**@positive.net> wrote:
I am designing a listing similar to a phone book in HTML. Each listing
has periods following it, but they must extend to the end of the table
cell, and not wrap.
The big problem here is how to implement the periods. Several approaches have
been suggested on such matters in c.i.w.a.stylesheets. Whether the whole idea
is feasible on the WWW is debatable. In any case, it would be more like a
styling issue than HTML. You don't really want to have masses of periods as
_content_ of your pages.
Is there any way to prevent the text from 1) wrapping within the table
cell
In HTML, several ways:

a) <td>foo&nbsp;bar</td> (or with &nbsp; replaced by the no-break space
character)

b) <td nowrap>foo bar</td> (suitable only if _all_ line breaks inside a cell
are to be suppressed)

c) <td><nobr>foo bar</nobr></td> (nonstandard but widely supported)

d) <td><pre>foo bar</pre></td> (has other effects as well, somewhat nastily)

In CSS, use white-space: nowrap.
and 2) causing the table cell to expand?
In HTML, no. The CSS side of the matter belongs to our sister group. It's not
trivial, but you could use table-layout: fixed for the table, set the cell
width, and set overflow: hidden for the cell. This would imply that essential
information will be made invisible to some users unless you are very careful.
You didn't think of setting the width in pixels, did you?
In other words, the filler
periods must flow past the right boundary of the cell (but not be seen).
Similar to:

[Ben's Car Shop.......................] [555-5555]


Is this really about telephone numbers, or what?

The recommended (by ITU) notation for telephone numbers does not use hyphens
but spaces. You could use the no-break space character, which works well,
whereas the nonbreaking hyphen is poorly supported.

In the WWW context, phone numbers should be expressed in the international
notation (starting with "+"), unless limited to a single country or other
numbering area and clearly indicated as such.

(Telephone numbers could be made links, using the tel: scheme. This might be
nice in the future when (or if) browsers support tel: URLs and let the user
just click on a number to make a phone call or send a text message. Then
again, if it became common, spammers would try to make use of it.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Mar 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.