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

How can I force clipping of text in a table cell?

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 overflow style to
hidden, but that doesn't work unless I set the table-layout style of
the table to fixed, which I cannot do. In the sample code below, it
correctly sets the width of the cell to 200, but the height gets
bigger and it wraps the text. If I add a <nobr> tag to the cell, the
text doesn't wrap any more, but the width gets real big (enough to fit
all the text).

<table width="200" border="1">
<tr>
<td height="20" width="200" id="tableCell" style="overflow:hidden">
So, here is some text that obviously will not fit in this lousy 200
pixel wide box.
</td>
</tr>
</table>

Thanks in advance.
Nov 18 '05 #1
1 1680
Not sure this is the best forum for this but I will answer with .Net solution.

Find out the make number of characters that can fit in the and use substring to trim those values.

For example:

string test = "this is a test that should only be 10 characters long";
test = test.Substring(0, 10);

This is assuming that your cell is wide enough to fit 10 characters.

Alan Washington
http://www.aewnet.com
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 overflow style to
hidden, but that doesn't work unless I set the table-layout style of
the table to fixed, which I cannot do. In the sample code below, it
correctly sets the width of the cell to 200, but the height gets
bigger and it wraps the text. If I add a <nobr> tag to the cell, the
text doesn't wrap any more, but the width gets real big (enough to fit
all the text).

<table width="200" border="1">
<tr>
<td height="20" width="200" id="tableCell" style="overflow:hidden">
So, here is some text that obviously will not fit in this lousy 200
pixel wide box.
</td>
</tr>
</table>

Thanks in advance


User submitted from AEWNET (http://www.aewnet.com/)
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and...
2
by: Paul E Collins | last post by:
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...
5
by: Harry | last post by:
CSS Description: Table contains a column of td cells with links. Achieved: 1. Entire link cells highlight when hovered. 2. The entire area of these cells are clickable. Problem:
3
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...
2
by: joltman | last post by:
OK, this is kind of hard to explain, so I'll do my best: I have a form where I have a row where there could be multiple entries, so I have a link where it will dynamically add another row like it,...
3
by: Steve | last post by:
I just noticed a bug on my site where if someone enters a continuous string of characters like "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" and I have that being rendered into a table with a width...
2
by: zeyais | last post by:
I am using ASP.net (should be transparent in this case). The page is generated alright. The page has fieldset, divs and tables and other HTML elements like text box, drop downs etc; all are...
5
by: bob | last post by:
Now this ought to be a simple matter. But nothing's simple in the Net world, I'm finding. In vb6 you could use "!" to force text to upper case in the format function. I've searched the vb.net...
1
by: meworkingman | last post by:
I'm a relative CSS newbie and I'm trying to do the following: I have a table that holds text that might span multiple cells. I want it to look something like this: ...
1
by: swetha123 | last post by:
hello , I need to alert the value entered in the text box,which is in TD cell, using DOM can any one tell how please here is the code with out a text box which is working <html> <head> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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:
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,...

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.