473,537 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12544
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
2469
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 change its text contents from a link elsewhere in the page? I have a rought idea that I'll need something like 'id' in my <td> tags but while I have...
2
36237
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 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...
2
2144
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, and this can happen as many times as you click on the link. This row consists of 2 drop-down boxes. Depending on the selection of the first...
3
1495
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 set to say.. 100, it will stretch the table to fit all those characters. Enforcing characters wouldn't really work cause the cell is allowed to...
1
1693
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 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,...
2
2825
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 standards. Also, the page is formatted/decorated using CSS. Here is the issue: HTML generated is alright. Except: 1. IE the text is clipped instead...
5
21317
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 help system and can't find any help on formatting text. There's plenty of help formatting numbers, dates, and times, though. I'm in the phase of...
1
2399
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: ----------------------------------| | Cell A1 | This is | Cell C1 | |-----------| overflow |----------| | Cell A2 | text that | Cell C2 | |-----------| covers |------------|...
1
4001
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> <script type="text/javascript"> function cell() { var x=document.getElementById('myTable').rows.cells; alert(x.innerHTML);
0
7359
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7680
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7275
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5823
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3342
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1756
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
920
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.