Html <td> width issue. Is it related to colspan? How? - html

My <td> width seems to be ignored for some reason related to the tabledatas above it since if I remove all rows except the row that seems to be having the issue, it then works fine.
I am thinking it has something to do with the colspans.
I saw this answer colspan width issue which talks about how you basically need to imagine there are invisible cells in your table, but I was already doing that, but maybe I am doing it wrong?
Here is the html
<table border="1" cellspacing="0" cellpadding="0" width="600">
<tr>
<td id="IX991PI1" rowspan="1" colspan="3" width="412" height="81" ></td>
<td id="OW6DMR2F" rowspan="1" colspan="1" width="188" height="81" ></td>
</tr>
<tr>
<td id="RU5UW85Z" rowspan="1" colspan="3" width="412" height="66" ></td>
<td id="RGPQDOYK" rowspan="2" colspan="1" width="188" height="204" ></td>
</tr>
<tr>
<td id="67JXVSFB" rowspan="1" colspan="3" width="412" height="138" ></td>
</tr>
<tr>
<td id="AB6FD7D5" rowspan="1" colspan="1" width="145" height="67" ></td>
<td id="RU0G6BL8" rowspan="1" colspan="3" width="455" height="67" ></td>
</tr>
<tr>
<td id="0B0D4ZVN" rowspan="1" colspan="4" width="600" height="29" ></td>
</tr>
<!-- the problematic row -->
<tr>
<td id="V4GHN5BW" rowspan="1" colspan="2" width="242" height="100" ></td>
<td id="CK3PB3OT" rowspan="1" colspan="2" width="358" height="100" ></td>
</tr>
</table>
Here is an image of the table as it is wrong and how it should look
As far as I can see, all widths add up to 600, and all colspans have the right amount keeping the invisible cells in mind (total of 4 cols). In fact, the problematic row is what's making there be 4 cols, so I would expect it to have full control on where that invisible line goes that cuts all the above and below rows.
I can't think of anything else that could be causing the issue other than the colspans, so I must be doing something wrong.
Edit- Also, this is for emails, so I am limited on css and such...
Edit- I was using google chrome and after trying it on firefox there seems to be no issue?
However, I then added more rows to the table to see if something won't work in both browsers, and I have quickly ran into that problem.
The bottom 4 rows are where the problems start (the first is the problematic row from above). Even putting those rows into their own table still has issues.
<table border="1" cellspacing="0" cellpadding="0" width="600" >
<tr>
<td id="5DPKU34O" rowspan="1" colspan="4" width="412" height="81" ></td>
<td id="XHK07WYR" rowspan="1" colspan="1" width="188" height="81" ></td>
</tr>
<tr>
<td id="5IP7MCTF" rowspan="1" colspan="4" width="412" height="66" ></td>
<td id="WO4JPVJ6" rowspan="2" colspan="1" width="188" height="204" ></td>
</tr>
<tr>
<td id="JLCGN4YY" rowspan="1" colspan="4" width="412" height="138" ></td>
</tr>
<tr>
<td id="RX6Q81VD" rowspan="1" colspan="1" width="145" height="67" ></td>
<td id="6YNA6379" rowspan="1" colspan="4" width="455" height="67" ></td>
</tr>
<tr>
<td id="4DIOQA09" rowspan="1" colspan="5" width="600" height="29" ></td>
</tr>
<!-- problem starts here -->
<tr>
<td id="0X3RX651" rowspan="1" colspan="2" width="242" height="50" ></td>
<td id="L1TLGZIX" rowspan="2" colspan="3" width="358" height="220" ></td>
</tr>
<tr>
<td id="U1BAFJFK" rowspan="1" colspan="2" width="242" height="170" ></td>
</tr>
<tr>
<td id="VPM6G120" rowspan="1" colspan="3" width="380" height="192" ></td>
<td id="LF6WV55J" rowspan="1" colspan="2" width="220" height="192" ></td>
</tr>
<tr>
<td id="DW95YX3T" rowspan="1" colspan="5" width="600" height="16" ></td>
</tr>
</table>
Here is an image illustrating the issue in Firefox and Chrome.

To set the widths of table columns that have colspans, the most reliable method is to set the width for each column explicitly using <col> elements.
That way, the browser will know from the start which column has which width, and also how many columns there actually are!
This method also has the advantage that you won't need to specify the width in each and every table cell, so it's more efficient in terms of bytes, and less error-prone in terms of typos.
<table border="1" cellspacing="0" cellpadding="0">
<col width="145"><col width="97"><col width="170"><col width="188">
<tr>
<td id="IX991PI1" colspan="3" height="81"></td>
<td id="OW6DMR2F" height="81"></td>
</tr>
<tr>
<td id="RU5UW85Z" colspan="3" height="66"></td>
<td id="RGPQDOYK" rowspan="2" height="204"></td>
</tr>
<tr>
<td id="67JXVSFB" colspan="3" height="138"></td>
</tr>
<tr>
<td id="AB6FD7D5" height="67"></td>
<td id="RU0G6BL8" colspan="3" height="67"></td>
</tr>
<tr>
<td id="0B0D4ZVN" colspan="4" height="29"></td>
</tr>
<!-- the no longer problematic row -->
<tr>
<td id="V4GHN5BW" colspan="2" height="100"></td>
<td id="CK3PB3OT" colspan="2" height="100"></td>
</tr>
</table>
I also took the liberty of removing all colspan=1 and rowspan=1 attributes, since those are not necessary. And the width attribute on the table itself was also superfluous.
Tested in Chrome and Mozilla, and it looks good in Thunderbird too.

Try to remove the width in your td in row problematic tag. This sets the maximum width for its child.
<!-- the problematic row -->
<tr>
<td id="V4GHN5BW" rowspan="1" colspan="2" height="100" ></td>
<td id="CK3PB3OT" rowspan="1" colspan="2" height="100" ></td>
</tr>

Related

HTML Table Design issue with 22 column in row with Menu collapse

I have one table shown on screen with menu layout.
While menu is not collapsed the table is showing perfectly on screen like the below image.
But once I Collapse the Menu toggle button the table design is getting out of screen like below image. Last 3 columns were out of screen body.
Below is the code for table I am using.
<table width="100%" border="1" cellpadding="1" cellspacing="2" bordercolor="#999999">
<tbody>
<tr>
<td height="24" width="20%">Customer</td>
<td width="15%">Purchase</td>
<td width="15%">Branch</td>
<td width="15%">Status</td>
<td width="15%">PO Issue date</td>
<td width="15%">Delivery Date</td>
<td width="15%">Return Date</td>
<td width="15%">Approved By</td>
<td width="15%">Equipment Recovery</td>
<td width="15%">Labor Recovery</td>
<td width="15%">Shipping Recovery</td>
<td width="15%">Purchase Recovery</td>
<td width="15%">Other Recovery</td>
<td bgcolor="#E6E6E6"><strong>Total</strong></td>
<td>Equipment Rental</td>
<td>Labor</td>
<td>Shipping</td>
<td>Equipment Purchase</td>
<td>Other</td>
<td>Tax</td>
<td>Loss Code</td>
<td nowrap="nowrap" width="100%">Internal Notes</td>
</tr>
<tr>
<td height="24" colspan="13">
<div align="right"><strong>TOTALS</strong></div>
</td>
<td bgcolor="#E6E6E6">$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td colspan="2"></td>
</tr>
</tbody>
</table>
Can anybody have look and let me know how I can overcome it.

I need help to split a cell into two columns

Just like how in the image I linked "tache1" and "tache2" in the 4th row are splitting "Mercredi" in two
<table width="400" border="2" cellspacing="1" cellpadding="1">
<tr>
<th width="15%" rowspan="2">Equipes</th>
<th width="70%" colspan="5">Janvier</th>
<td width="15%" rowspan="2"></td>
</tr>
<tr>
<th>Lundi</th>
<th>Mardi</th>
<th>Mercredi</th>
<th>Jeudi</th>
<th>Vendredi</th>
</tr>
<tr>
<td rowspan="2">Equipe1</td>
<td colspan="3">tache1</td>
<td colspan="2">tache2</td>
<td rowspan="2">Semaine1</td>
</tr>
<tr>
<td colspan="2">tache1</td>
<td colspan="3">tache2</td>
</tr>
</table>
Use 6 colspan instead of 5 in <th width="70%" colspan="6">Janvier</th> Then use 2 colspan for Mercredi like this <th colspan="2">Mercredi</th> Then use 3 colspan for each tache like this
<td colspan="3">tache1</td>
<td colspan="3">tache2</td>
Also In your setup, Equip1 is taking 2 rows but its content to the right take only 1 row.
so use rowspan"1" for both Equipe1 and 2.
<table width="600" border="2" cellspacing="1" cellpadding="1">
<tr>
<th width="15%" rowspan="2">Equipes</th>
<th width="70%" colspan="6">Janvier</th>
<td width="15%" rowspan="2"></td>
</tr>
<tr>
<th>Lundi</th>
<th>Mardi</th>
<th colspan="2">Mercredi</th>
<th>Jeudi</th>
<th>Vendredi</th>
</tr>
<tr>
<td rowspan="1">Equipe1</td>
<td colspan="3">tache1</td>
<td colspan="3">tache2</td>
<td rowspan="2">Semaine1</td>
</tr>
<tr>
<td rowspan="1">Equipe2</td>
<td colspan="3">tache1</td>
<td colspan="3">tache2</td>
</tr>
</table>

How to align two TD with different length in same row<tr>

Please help me how to align this structure properly. I would like to decrease the size of td "Todays Special" to considerable height. This td grows based on my value say if new fruits added then the header td also grows.
Be kind to help me to resolve this
<table>
<tr>
<td class="title">Todays Special</td>
<td>
<div style="height: 120px; width:100%;overflow-y:auto;">
<table style="height: auto; width:100%;" valign="top">
<tbody>
<tr style="vertical-align: baseline;">
<td colspan="4" class="title">6</td>
<td colspan="4" class="title">mango</td>
</tr>
<tr style="vertical-align: baseline;">
<td colspan="4" class="title">23</td>
<td colspan="4" class="title">orange</td>
</tr>
<tr style="vertical-align: baseline;">
<td colspan="4" class="title">29</td>
<td colspan="4" class="title">banana</td>
</tr>
<tr style="vertical-align: baseline;">
<td colspan="4" class="title">47</td>
<td colspan="4" class="title">papaya</td>
</tr>
<tr style="vertical-align: baseline;">
<td colspan="4" class="title">11959</td>
<td colspan="4" class="title">kiwi</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</table>
If you edit the "Todays Special" td, you can set the desired width and font-size through the style property of the td tag. And also set the alignment you want.
As you are not making a Table header from a row, you have to set different styles to the main td and the rest of the table.
Hope I helped.
Assuming you just want to match the height of the column Todays's Special. You can do this by adding the rowspan according to the no. of items in the list
<td class="title" rowspan="5">Todays Special</td>
<div>
<table style="height: auto;" valign="middle">
<tbody>
<tr>
<td class="title" rowspan="5">Todays Special</td>
<td class="title">6</td>
<td class="title">mango</td>
</tr>
<tr>
<td class="title">23</td>
<td class="title">orange</td>
</tr>
<tr>
<td class="title">29</td>
<td class="title">banana</td>
</tr>
<tr>
<td class="title">47</td>
<td class="title">papaya</td>
</tr>
<tr>
<td class="title">11959</td>
<td >kiwi</td>
</tr>
</tbody>
</table>
</div>

Aligning elements in table

I would like for top 4 elements to stretch across the top, and bottom two to also look like they belong to the same table, stretch and not be so squeezed. Can I accomplish this without adding empty <td>s?
This is how it looks like right now:
http://www.w3schools.com/code/tryit.asp?filename=F0OOEL3HH55Y
My code:
<table cellspacing="2" cellpadding="2" width="650" border="0">
<tr>
<td height="8" class="header" width="300">Weight Per Book (lb.)</td>
<td height="8" class="header" width="300">Cost per Book</td>
<td height="8" class="header" width="200">Quantity for whole order</td>
<td height="8" class="header" width="400">Capability Complexity Level For TO</td>
</tr>
<tr>
<td height="16">2.0</td>
<td height="16">0.00</td>
<td height="16">0</td>
<td height="16">4</td>
</tr>
<tr valign="bottom">
<td class="header">Distribute ID Order to Home Plant</td>
<td class="header">Distribute All OTR's to Home Plant</td>
</tr>
<tr>
<td>No</td>
<td>No</td>
</tr>
</table>
You can use the colspan attribute to do that. This attribute define the number of columns a particular cell should span.
Here is an example:
<table cellspacing="2" cellpadding="2" width="650" border="0">
<tr>
<th colspan="4">Production</th>
</tr>
<tr>
<td height="8" class="header" width="300">Weight Per Book (lb.)</td>
<td height="8" class="header" width="300">Cost per Book</td>
<td height="8" class="header" width="200">Quantity for whole order</td>
<td height="8" class="header" width="400">Capability Complexity Level For TO</td>
</tr>
<tr>
<td height="16">2.0</td>
<td height="16">0.00</td>
<td height="16">0</td>
<td height="16">4</td>
</tr>
<tr valign="bottom">
<td colspan="2" class="header">Distribute ID Order to Home Plant</td>
<td colspan="2" class="header">Distribute All OTR's to Home Plant</td>
</tr>
<tr>
<td colspan="2">No</td>
<td colspan="2">No</td>
</tr>
</table>
Hope this helps!

How do I get a table with 3 columns and the third colums only has 1<td> 100%

<html>
<body>
<table align="left" border="0" cellpadding="1" cellspacing="1" style="width: 1000px;">
<tbody>
<tr>
<td width="300">Hanrathsingel 14</td>
<td width="300">Home</td>
<td width="400" height="100%">This one has to take the full height of the table</td>
</tr>
<tr>
<td width="300">1252 AE Laren</td>
<td width="300">Wie zijn wij</td>
</tr>
<tr>
<td width="300">T. 035-6231419</td>
<td width="300">Informatie</td>
</tr>
<tr>
<td width="300">M. 06-21700357</td>
<td width="300">Algemene Voorwaarden</td>
</tr>
<tr>
<td width="300">laren#qualitysites4all.com</td>
<td width="300">Contact</td>
</tr>
</tbody>
</table>
</body>
</html>
How do I get the column to be 100% of the table height but the other columns must keep their height?
Because I want to put a widget in there but I have to work in my boss his cms and I am not allowed to make new divs :(
Try rowspan:
<table align="left" border="0" cellpadding="1" cellspacing="1" style="width: 1000px;">
<tbody>
<tr>
<td width="300">Hanrathsingel 14</td>
<td width="300">Home</td>
<td width="400" rowspan="5">This one has to take the full height of the table</td>
</tr>
<tr>
<td width="300">1252 AE Laren</td>
<td width="300">Wie zijn wij</td>
</tr>
<tr>
<td width="300">T. 035-6231419</td>
<td width="300">Informatie</td>
</tr>
<tr>
<td width="300">M. 06-21700357</td>
<td width="300">Algemene Voorwaarden</td>
</tr>
<tr>
<td width="300">laren#qualitysites4all.com</td>
<td width="300">Contact</td>
</tr>
</tbody>
</table>
Example
JSFiddle Example
Use rowspan="5" in that TD.
Rowspan attribute, tells your element to "get the height" of 5 rows in this case.
If you have dinamic content remember to update this value to the actual number of rows of your table.