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

Prevent text wrap in a table cell

P: n/a
I need to 'clip' text in a table cell instead of wrapping it, such that (i)
the cell keeps its specified fixed width and (ii) any text that overflows
the cell should be 'clipped' (hidden or truncated) rather than wrapping to
create a new line in the cell.

If the actual content of the clipped cell is "Hello world", it should look
something like this:

+--------+------------+
|Hello wo|second cell |
+--------+------------+

I'm aware that this is not a particularly pleasant thing to be doing, but it
is required for HTML reports in my workplace. I'll also accept CSS hacks :)

Thanks for any help.

P.
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Paul E Collins" <fi******************@CL4.org> wrote:
I need to 'clip' text in a table cell instead of wrapping it,
You cannot clip anything in HTML.
such
that (i) the cell keeps its specified fixed width and (ii) any text
that overflows the cell should be 'clipped' (hidden or truncated)
rather than wrapping to create a new line in the cell.
Then you want to use CSS with table { table-layout: fixed; } and
td { white-space: nowrap; overflow: hidden; }. Usual caveats apply, _and_
special caveats apply to using these techniques, since they easily cause
content to be hidden in a manner you didn't mean to. The table should be
designed very carefully, using width settings for columns as needed, in
em units. And things can still go wrong. In particular, IE does not honor
the element's padding in overflow situations.
If the actual content of the clipped cell is "Hello world", it should
look something like this:

+--------+------------+
|Hello wo|second cell | +--------+------------+
Normally you should try and handle truncations when generating the
document, noi in the presentation phase. When done in generation,
the generating program can insert some indication of truncation having
taken place (e.g., "Hello wo..."), so that the user won't think the page
really says "Hello wo".
I'm aware that this is not a particularly pleasant thing to be doing,
but it is required for HTML reports in my workplace.
So is this about WWW authoring, or will (for example) all users have
identical browsers? This makes a big difference in a formatting issue
like this. (But remember that not all people have identical eyesight,
maybe not even identical monitors and resolution, so don't even think
about px dimensioning.)

As usual, a URL would help in considering what might be the optimal
approach.
I'll also accept CSS hacks :)


If you expected to find HTML solutions to the problem and regarded CSS as
a potential source of hacks, you got the roles all wrong.

Copy sent to c.i.w.a.stylesheets, followups set there.

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

Jul 20 '05 #2

P: n/a
"Paul E Collins" <fi******************@CL4.org> wrote:
I need to 'clip' text in a table cell instead of wrapping it,
You cannot clip anything in HTML.
such
that (i) the cell keeps its specified fixed width and (ii) any text
that overflows the cell should be 'clipped' (hidden or truncated)
rather than wrapping to create a new line in the cell.
Then you want to use CSS with table { table-layout: fixed; } and
td { white-space: nowrap; overflow: hidden; }. Usual caveats apply, _and_
special caveats apply to using these techniques, since they easily cause
content to be hidden in a manner you didn't mean to. The table should be
designed very carefully, using width settings for columns as needed, in
em units. And things can still go wrong. In particular, IE does not honor
the element's padding in overflow situations.
If the actual content of the clipped cell is "Hello world", it should
look something like this:

+--------+------------+
|Hello wo|second cell | +--------+------------+
Normally you should try and handle truncations when generating the
document, noi in the presentation phase. When done in generation,
the generating program can insert some indication of truncation having
taken place (e.g., "Hello wo..."), so that the user won't think the page
really says "Hello wo".
I'm aware that this is not a particularly pleasant thing to be doing,
but it is required for HTML reports in my workplace.
So is this about WWW authoring, or will (for example) all users have
identical browsers? This makes a big difference in a formatting issue
like this. (But remember that not all people have identical eyesight,
maybe not even identical monitors and resolution, so don't even think
about px dimensioning.)

As usual, a URL would help in considering what might be the optimal
approach.
I'll also accept CSS hacks :)


If you expected to find HTML solutions to the problem and regarded CSS as
a potential source of hacks, you got the roles all wrong.

Copy sent to c.i.w.a.stylesheets, followups set there.

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

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.