473,169 Members | 240 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,169 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 36206
"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
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
3
by: efe2023 | last post by:
Hello Everybody, There is SQL Server 2008 R2 database with MS Access front-end (linked ODBC tables). I can see all linked tables in MS Access and can add new rows. However, when trying to update...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: SumanSingh | last post by:
Hey everyone! I'm a college student (Engineering in computer science) super eager to dive into the world of Data Science for my career. Any tips or advice from your own journey? What are some...
0
by: SumanSingh | last post by:
As a third-year college student, I'm eager to enhance my SQL skills. Can you recommend valuable resources or courses that would be beneficial for me to learn SQL effectively?
0
by: saichinnu1852 | last post by:
I am trying to use Collibra by installing it using AWS Marketplace AMI that they offer and launched the EC2 instance. However, when I try to login to Collibra using the IP Address of the EC2 instance...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...

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.