473,402 Members | 2,055 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,402 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). Thanks in advance.
<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>
Jul 23 '05 #1
3 12534
john wrote;
I want to set the cell width and height such that the cell doesn't get
bigger.
Imposible. Width is possible using table-layout:fixed (which doesn't
necessarily work...)
If the text is too long for the cell, it should be clipped.


Wrap you content in another element.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 23 '05 #2
john wrote:
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). Thanks in advance.
<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>


A style rule like this:

td {width:200px; height:1em; overflow:hidden}

should, in theory, do the job. No?
Matthias

Jul 23 '05 #3
Matthias Gutfeldt wrote;
A style rule like this:

td {width:200px; height:1em; overflow:hidden}

should, in theory, do the job. No?


No. Read table layout algorithms in CSS2 spec.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 23 '05 #4

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...
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...
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...
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> ...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.