HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2012, 08:51 AM
lelales lelales is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2008
Posts: 601 lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 40 m 3 sec
Reputation Power: 37
<td width> not working

Hi, when I use javascript (say jQuery, or Scriptaculous, or Prototype) on my web page my Table formatting does not work.
For example, I would have
Code:
<td width="40">

But the width property doesn't work.

Does anyone know why this happens, and what the work around is? I know I could use CSS, but it's basically data in a table, and needs the <td>'s need to be a specific width.

thanks!
-

Last edited by lelales : October 25th, 2012 at 08:52 AM. Reason: typo

Reply With Quote
  #2  
Old October 26th, 2012, 01:33 AM
Heatleakz Heatleakz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Location: Stockholm, Sweden
Posts: 16 Heatleakz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 27 m 22 sec
Reputation Power: 0
Send a message via XFire to Heatleakz
Quote:
Originally Posted by lelales
Hi, when I use javascript (say jQuery, or Scriptaculous, or Prototype) on my web page my Table formatting does not work.
For example, I would have
Code:
<td width="40">

But the width property doesn't work.

Does anyone know why this happens, and what the work around is? I know I could use CSS, but it's basically data in a table, and needs the <td>'s need to be a specific width.

thanks!
-


Hi lelales,

To get a <td> element to hold it's given width you will need to specify the width attribute to 100% for the <table> element.

Code:
<table width="100%">
<tr>
<td width="40"></td>
</tr>
</table>

Reply With Quote
  #3  
Old October 26th, 2012, 02:33 AM
davikerkrish davikerkrish is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 18 davikerkrish User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 11 m 40 sec
Reputation Power: 0
You can use the following code

<td style="width:40px;">

Then let me know with the result.

Reply With Quote
  #4  
Old October 26th, 2012, 08:19 AM
lelales lelales is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2008
Posts: 601 lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level)lelales User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 40 m 3 sec
Reputation Power: 37
Thanks hHeatleakz

I'll give a try later today.
Thanks so much!

Last edited by lelales : October 26th, 2012 at 08:57 AM. Reason: typo

Reply With Quote
  #5  
Old October 26th, 2012, 08:53 AM
MauroEldritch's Avatar
MauroEldritch MauroEldritch is offline
Contributing User
Click here for more information
 
Join Date: Oct 2012
Location: Buenos Aires, Argentina
Posts: 64 MauroEldritch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 5 sec
Reputation Power: 1
Also, if you want to use relative values you can use:

<td style="width:40%;">

If you want a more accurate number:

<td style="width:40.5%;">

You may use the number you want and decimals. See ya.

Reply With Quote
  #6  
Old October 26th, 2012, 08:57 AM
piperpam27 piperpam27 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 47 piperpam27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 51 m 3 sec
Reputation Power: 1
Quote:
Originally Posted by Heatleakz
Hi lelales,

To get a <td> element to hold it's given width you will need to specify the width attribute to 100% for the <table> element.

Code:
<table width="100%">
<tr>
<td width="40"></td>
</tr>
</table>



Ummm...that's not true.

The following would work fine:
Code:
<table width="300">
    <tr>
        <td width="60">
            Foo
        </td>
        <td>
            Bar
        </td>
    </tr>
</table>


You just need to keep in mind a couple of simple rules.

1. Your specified td widths will not work if the sum of them all is less than (or greater than) than the specified width of the table. For example, if in the above example I told both of the TDs to be 20 pixels wide, then told the table to be 300 pixels wide--that would not add up, so it not display your specified TD widths. The standard work around for this is to have at least one TD with no specified width at all. This will cause all of the TDs with specified widths to work, and the extra will be shoved into the TD without a specified width.

2. You should style your tables with CSS.
Rather than using inline attributes for your TD widths, you should do it like this:
Code:
 
<table style="width: 300px;">
    <tr>
        <td style="width: 60px;">
            Foo
        </td>
        <td>
            Bar
        </td>
    </tr>
</table>

Reply With Quote
  #7  
Old November 3rd, 2012, 04:35 AM
BrightIdea BrightIdea is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 31 BrightIdea Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 5 h 5 m 21 sec
Reputation Power: 0
Width is a horrid and bogus tag, not recognised by xhtml.

Learn CSS2

Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > <td width> not working

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap