473,395 Members | 1,763 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,395 software developers and data experts.

Prevent text wrap in a table cell

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
2 36225
"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Roderik | last post by:
Hi, When I use <pre> inside my <td> cells, the text won't flow to a new line and the table gets to large in width. This will appear in Firefox this way, Internet Explorer will wrap the lines,...
12
by: sneill | last post by:
Hello, I have the following HTML / CSS that draws 2 rows. Each row has 3 cells. I want the cells within each row to span a single line. Each cell is 100px wide, and the row containing them is...
1
by: john | last post by:
I want to set the cell width and height such that the cell doesn't get bigger. If the text is too long for the cell, it should be clipped. It only has to work for IE. I have tried setting the...
14
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36)...
2
by: Yeah | last post by:
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. ...
2
by: amitp | last post by:
hi i'm using MS Word2003 for my VB application which is a report. The word documents contains tables and the cells inside the table contain some fields. My application replaces the field values with...
1
by: bussasrinivas | last post by:
How to wrap up text shown with a table cell after a certain length intervals ? -------------------------------------------------------------------------------- I have a requirement to wrap a...
1
by: asafok | last post by:
hi, i'm tring to get access to a cell inside a table that has the vlaue of an Email address but is not clickable. i tring to go to that cell and Wrap the inner text with <a href="mailto... tag so...
1
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.