How to fix the width of a td tag.

Hello,

I try to fix the width of columns :
<td fixed width = 180>test</td>

But the result is that the td tag wraps the text and the td is not wider than the text.

How can I do ?

Thank you.


laurent_diepAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
COBOLdinosaurConnect With a Mentor Commented:
If what you are trying to do is push out the cell size, try doing it this way:

<td width="180" nowrap>test</td>

Cd&
0
 
jusnoksoCommented:
Solution which I usually use are empty transparent 1x1 px gif's. Just create one and put the <img scr="1x1.gif" height="1" width="180" alt=""><br> to your code, it stretches the <td> and keeps the correct size in no mather what.
0
 
COBOLdinosaurCommented:
jusnosko,

Welcome to Experts-Exchange.  Please read the guidelines for comments and answers.  We submit with comments only unless what we are providing is definitive and complete.  It may turn out that your comment provides a solution, but by posting it as an answer you have removed the question from the active list which will limit discussion.  

Most members of the community would consider your action disrespectful of the user.  Please refrain from doing this in the future.

laurent_diep,

Cell sizing problems can have a number of causes and solutions, and if multiple browsers need to be support it becomes even more difficult.  If the proposed solution does not completely solve the problem, you should reject that, and give us a little more information, about the content of the cell and the browsers you need to support.  posting more of the code or a link to the page would also help.

Cd&
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jusnoksoCommented:
sorry for that, it was my first answer.. I'll know next time :)
0
 
COBOLdinosaurCommented:
No problem happens all the time.  If you are just starting out on the site, you may find some of the threads in this topic area helpful:

http://www.experts-exchange.com/new_users/

Cd&
0
 
MindphaserCommented:
jusnokso

Don't worry, I rejected it for now. Let's see, maybe you still get the points.

** Mindphaser - Community Support Moderator **

0
 
endamcgCommented:
Hi

jusnokso's comment is quite a common way but note that it also can depend on yout table properties.

If your table is width=100% for example you should try to match your cells to that.
I almost always work with fixed with tables and cells.

Try something like
<table width="650" summary="">
<tr>
 <td width="180"> content </td>
</tr>
<tr>
 <td width="350"> content </td>
</tr>
<tr>
 <td width="120"> content </td>
</tr>

Or you could define all width's using percentages and add felxibility to your table.

Personally I think its best to avoid always using transparent gifs to define your table props, it has caused my problems in the past so I never do it anymore.


0
 
jusnoksoCommented:
"Personally I think its best to avoid always using transparent gifs to define your table props, it has
caused my problems in the past so I never do it anymore."

What kind of problems are u talking 'bout? I've been working as a front-end coder for four years now, and haven't had any problems with those transparent images, contrary.

Defining table and td widths isn't allways enough. Especially NN4.x will stretch your tables according to the td's content, not by the width atribute.
0
 
COBOLdinosaurCommented:
laurent_diep,

Unless you provide some feed back it is not like you are going to get much help.  We need mor infromation about the setup of thei table and it you don't give it to us, then it is just a guessing game.  

If you want a solution, then participate.

Cd&

0
 
mv_sureshCommented:
<td style="width=180">

try this, hope this should work for you
0
 
COBOLdinosaurCommented:
mv_suresh,

Did you not read the comments in this thread before you posted.  style="width:180" in no different than what has already been posted.  You have been on the site long enough to know better then to use the answer button for such a comment.  I will refer this to the moderators.

I guess part of the problem here is the failure of laurent_diep to give any kind of meaningful response.

Cd&
0
 
MindphaserCommented:
mv_suresh

I rejected your comment per request. COBOLdinosaur gave you a good reason for this rejection. You can always reread our "How to" at http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp

** Mindphaser - Community Support Moderator **
0
 
mv_sureshCommented:
I am sorry, I never read all the answers.

0
 
MindphaserCommented:
mv_suresh

I think it is part of community sense that you 'listen' to what other people 'say' before you give an answer. These written discussions work like a live discussion. If you don't know what people talk about, it would be better not to comment at all ... That is one big difference here versus newsgroups where people comment without any rules ...

0
 
laurent_diepAuthor Commented:
mv_suresh, endamcg, jusnokso : Thank you to answer.

COBOLdinosaur : I tried your "nowrap" option succesfully so the points come to you.

Thanks again.

Laurent_Diep.

0
 
COBOLdinosaurCommented:
Glad we could help.  Thanks for the A. :^)

Cd&
0
All Courses

From novice to tech pro — start learning today.