473,808 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making a <td> as small a width as possible

I have a <tdthat contains several elements, some of which are
left-aligned, right-aligned, or centered. I do not know the widths of these
elements beforehand, so I cannot give my <tda fixed width. I want the <td>
to have as small a width as possible without causing anything to wrap, but
IE seems to want to make it bigger. Does anybody know of a good way to
prevent a <tdfrom being stretched to a larger width than necessary?
Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Oct 6 '07 #1
4 4133
"Nathan Sokalski" <nj********@hot mail.comwrote in message
news:uR******** ******@TK2MSFTN GP03.phx.gbl...

[cross-posting removed]
>I have a <tdthat contains several elements, some of which are
left-aligned, right-aligned, or centered. I do not know the widths of these
elements beforehand, so I cannot give my <tda fixed width. I want the
<tdto have as small a width as possible without causing anything to wrap,
but IE seems to want to make it bigger. Does anybody know of a good way to
prevent a <tdfrom being stretched to a larger width than necessary?
A <tdwill expand to fit its contents. However, if other rows have more
data in the corresponding cell, then obviously the entire column will expand
to fit the contents of the largest cell.

Check in View Source for what markup is actually being included in the cell
in question...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 6 '07 #2
Here is an example of a <tdusing more space than necessary:

<table>
<tr>
<td>
<span style="float:le ft;">Float Left</span>
<span style="float:ri ght;">Float Right</span><br/>
<div
style="width:50 0px;height:500p x;background-color:Orange;"> &nbsp;</div>
</td>
</tr>
</table>

You will notice that neither the table or td has a set width, but the float
right hangs over the edge of the div. The table could easily be no more than
the width of the div (in this case 500px) and still fit both span tags in.
Do the floats have anything to do with the problem? I use floats because I
want the spans on the left and right of the same line, and in my code the
width of the div is dynamic (my code also involves more cells than this).
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:u3******** ******@TK2MSFTN GP06.phx.gbl...
"Nathan Sokalski" <nj********@hot mail.comwrote in message
news:uR******** ******@TK2MSFTN GP03.phx.gbl...

[cross-posting removed]
>>I have a <tdthat contains several elements, some of which are
left-aligned, right-aligned, or centered. I do not know the widths of
these elements beforehand, so I cannot give my <tda fixed width. I want
the <tdto have as small a width as possible without causing anything to
wrap, but IE seems to want to make it bigger. Does anybody know of a good
way to prevent a <tdfrom being stretched to a larger width than
necessary?

A <tdwill expand to fit its contents. However, if other rows have more
data in the corresponding cell, then obviously the entire column will
expand to fit the contents of the largest cell.

Check in View Source for what markup is actually being included in the
cell in question...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 6 '07 #3
Hello,

If the containing table and td have no width set, the td width will be the
size of the column.

To prevent the wrapping, use the nowrap attribute. See
http://www.htmlcodetutorial.com/tables/_TD_NOWRAP.html

--
Singapore Web Design
http://www.bootstrike.com/Webdesign/
Singapore Web Hosting
http://www.bootstrike.com/WinXP/faq.html
Windows XP FAQ

"Nathan Sokalski" <nj********@hot mail.comwrote in message
news:uR******** ******@TK2MSFTN GP03.phx.gbl...
>I have a <tdthat contains several elements, some of which are
left-aligned, right-aligned, or centered. I do not know the widths of these
elements beforehand, so I cannot give my <tda fixed width. I want the
<tdto have as small a width as possible without causing anything to wrap,
but IE seems to want to make it bigger. Does anybody know of a good way to
prevent a <tdfrom being stretched to a larger width than necessary?
Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Oct 6 '07 #4
On Oct 6, 4:20 am, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
Here is an example of a <tdusing more space than necessary:

<table>
<tr>
<td>
<span style="float:le ft;">Float Left</span>
<span style="float:ri ght;">Float Right</span><br/>
<div
style="width:50 0px;height:500p x;background-color:Orange;"</div>
</td>
</tr>
</table>
Hi Nathan

you have to set clear:both to make the div element go below

<div style="CLEAR:BO TH;width:500px; height:500px;ba ckground-
color:Orange;">

Hope it helps

Oct 6 '07 #5

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

Similar topics

6
1741
by: Mel | last post by:
is it possible ? i tried size=100% and 'NADA !' thanks, Mel
2
5786
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
8
8323
by: effendi | last post by:
Hi everyone Sorry to ask such a simple question. I created a table with 18 columns- 16 of which represent weeks starting from 1 to 16. In each cell I have a field which takes either a Null value or and "X". Since I only have at most one (1)character, I would like to make the td with as small as possible. I have placed width="5px" but it does seem to work. Can anyone suggest how I can make the cell smaller? Thanks
3
1709
by: RC | last post by:
I have a very sime html table like <html><head><title>My Table</title> <style> input { margin: 0; padding: 0; border-width: 0; text-indet: 0; text-align: left } </style></head><body> <table border="1" width="100%"> <caption>Table Title</caption> <tr>
1
3196
by: neverstill | last post by:
hi- I have a table on a page there is 1 row and 2 cells cell 1 has a user control that is basically just a DataList nested in a table o fit's own. then, below that user control I have some <p> tags to give me vertical space, then after that I have an <asp:image> control. Now, I just added the asp:image control. when I did, it put about 10-12
5
4597
by: Magnus Blomberg | last post by:
Hello! I have a table with several rows with text. I want to make the complete cell (or row) clickable as a link/href. Writing <a href...><td>bla bla</td></a> is not possible. If this is possible I have to add several spaces to the text (bla ) to make the clickable area larger. If I have to do this, how to disable the feature that formats the text as a link (becames blue and underlined).
3
1560
by: waqasahmed996 | last post by:
hello i have a problem that i fix width of <td> e.g. width="25" but when data is entered larger than this width than it disturb whole page because it go like this wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww i want that it should go like this wwww
3
2676
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/td-position.html In Internet Explorer, the "hello, world!" text is on top on the red box is on the bottom. In Firefox, the "hello, world!" text is on top and the red box is in the middle. Internet Explorer's rendition is the preferred rendition. Any idea as to how to make Firefox's rendition look more like Internet Explorer's? Thanks!
4
5294
by: harryusa | last post by:
I am trying to center 2 images concentrically which are z-indexed to lay on top of each other making an image with a border from another image that has a transparent center. I need the images to be horizonally and vertically centered within a <TD> </TD> area. No matter what I do the two image just present one above the other, albeit centered, NOT on top of each other. I originally did the entire page layout in TABLES until I found out I.E. 7...
0
9721
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10374
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9196
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4331
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
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.