473,401 Members | 2,146 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,401 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 36227
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.