如何增加HTML表中列的宽度?

如何增加HTML表中列的宽度?,html,html-table,width,cell,Html,Html Table,Width,Cell,如何增加HTML表中列的宽度 下面是我的代码。我试图将每行中的第二个标记展开,以便在输入文本框(第一个标记)和cookie名称及其价格(第三个标记)之间有更多的空间。有什么想法吗 <!--Order Info. table -nested table 2 --> <!--This is the first nested table within the main table --> <table border="0" width="65%" cell

如何增加HTML表中列的宽度

下面是我的代码。我试图将每行中的第二个
标记展开,以便在输入文本框(第一个
标记)和cookie名称及其价格(第三个
标记)之间有更多的空间。有什么想法吗

<!--Order Info. table -nested table 2 -->
<!--This is the first nested table within the main table -->
        <table border="0" width="65%" cellpadding="2">
        <!--Row 1 -->
                <tr>
                    <th colspan="3" align="left">Order Information</th>
                </tr>
        <!--Row 2 -->   
                <tr>
                    <td>QTY</td>
                    <td colspan="15"></td>
                    <td>Subtotal</td>
                    <td colspan="90"><input name="Gift Wrapping" id="Gift Wrapping" type="checkbox" /> Gift wrapping? (Additional charge of 1.95 per box)</td>
                </tr>
        <!-- Row 3 -->  
                <tr>
                    <td><input name="quantitya" id="quantitya" size="3" type="textbox" value="0"/></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Chocolate Nut - $10.99</td>
                    <td><input name="subtotala" id="subtotala" size="10" type="textbox" value="0"/></td>
                    <td colspan="40">If yes, note the text for the gift card:</td>
                </tr>
        <!-- Row 4 -->  
                <tr>
                    <td><input name="quantityb" id="quantityb" size="3" type="textbox" value="0"/></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Chocolate Chip - $9.99</td>
                    <td><input name="subtotalb" id="subtotalb" size="10" type="textbox" value="0"/></td>
                    <td colspan="5"><textarea wrap="soft" name="giftcardtext" id="giftcardtext" rows="3" cols="20" ></textarea></td> 
                </tr>
        <!--Row 5 -->
                <tr>
                    <td><input name="quantityc" id="quantityc" size="3" type="textbox" value="0"/></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Macadamia Nut - $12.99</td>
                    <td><input name="subtotalc" id="subtotalc" size="10" type="textbox" value="0"/></td> 
                </tr>
        <!--Row 6 -->
                <tr>
                    <td><input name="quantityd" id="quantityd" size="3" type="textbox" value="0"/></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Oatmeal Raisin - $10.99</td>
                    <td><input name="subtotald" id="subtotald" size="10" type="textbox" value="0"/></td> 
                </tr>
        <!--Row 7 -->
                <tr>
                    <td><input name="quantitye" id="quantitye" size="3" type="textbox" value="0"/></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Chocolate Dessert - $10.99</td>
                    <td><input name="subtotale" id="subtotale" size="10" type="textbox" value="0"/></td></td>
                    <td>Shipping:</td>
                    <td colspan="30"></td>
                    <td colspan="150">$5.95 for 1-5 boxes, $10.95 for five or more boxes</td>
                </tr>
        <!--Row 8 -->
                <tr>
                    <td><input name="quantityf" id="quantityf" size="3" type="textbox" value="0"/></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Butter - $7.99</td>
                    <td><input name="subtotalf" id="subtotalf" size="10" type="textbox" value="0"/></td></td>
                    <td>Total:</td>
                    <td colspan="30"></td>
                    <td colspan="1"><input name="totala" id="totala" size="3" type="textbox" value="0.00" /></td>
                </tr>
        <!--Row 9 -->
                <tr>
                    <td colspan="0"></td>
                    <td colspan="4"></td>
                    <td colspan="11" align="left">Subtotal</td>
                    <td><input name="subtotalg" id="subtotalg" size="10" type="textbox" value="0" /></td></td>
                </tr>
        </table>

订单信息
数量
小计
礼品包装?(每盒额外收费1.95元)
巧克力坚果-10.99美元
如果是,请注意礼品卡的文字:
巧克力片-9.99美元
澳洲坚果-12.99美元
燕麦葡萄干-10.99美元
巧克力甜点-10.99美元
航运:
1-5盒5.95美元,5盒或更多盒10.95美元
黄油-7.99美元
总数:
小计

您可以使用内联样式为列指定宽度

<td style="width: 50%">

顺便说一下,变化巨大的
colspan
值看起来非常奇怪。它们应该达到什么目的?

如果表列之间需要更多空间,可以使用CSS边距/宽度属性和任何适合您的值。我强烈反对在html代码中包含html视觉格式,尽管如果您这样做,请花时间了解一些html属性的含义,因为“colspan”不指定tds之间的宽度,而是将它们组合成一个td。

您可以以像素或百分比为单位:

<TABLE BORDER="2" CELLPADDING="2" CELLSPACING="2" WIDTH="300">
<TR>
<TD WIDTH="100">Column 1</TD>
<TD WIDTH="200">Column 2</TD>
</TR>
</TABLE>

第1栏
第2栏


第1栏
第2栏
此处的单元格数据

将数字替换为所需的任何宽度。请注意,列将是整个表中的最大大小。因此,如果第2列在第1行中是200px,第2行中是300px,那么该列在所有行中都将是300px。

解决Jared Updike提出的colspan问题后,我会使用CSS检查并增加的值。

我认为colspan可以让你告诉td占据右边的下一个td单元,并且不会影响实际的像素宽度。。。表中有90列还是40列?正如@Jared所暗示的,
colspan
是列的计数,而不是像素宽度。里面有一个
colspan=180
!哎哟正如其他人指出的那样,您正在错误地使用colspan标记。把这些拿出来,从那里开始。@Jared,pavium&Matt-谢谢你指出我在使用colspan时的错误。我想我认为我用得对,但显然不是@Jared和@pavium-不,我没有显示90、40或180列。我就是这样做的,因为这是我唯一能弄清楚如何增加细胞宽度的方法。有什么想法吗?
td.column1 { padding-right: 64px }
<TABLE BORDER="2" CELLPADDING="2" CELLSPACING="2" WIDTH="300">
<TR>
<TD WIDTH="100">Column 1</TD>
<TD WIDTH="200">Column 2</TD>
</TR>
</TABLE>
<TABLE BORDER="2" CELLPADDING="2" CELLSPACING="2" WIDTH="100%">
<TR>
<TD WIDTH="25%">Column 1</TD>
<TD WIDTH="75%">Column 2</TD>
</TR>
</TABLE>
<td style="width: 100px;">Cell data here</td>