HTML生成空

时间:2016-08-12 11:53:30

标签: html html-table

该表似乎在<td><td>部分的开头生成一个空的<th>单元格。任何想法为什么它这样做以及如何解决它?

<table>
	<th>
	 <td>Vintage</td>
	 <td>Product Name</td>
	 <td>Size</td>
	 <td>Qty</td>
	 <td>Per Bottle Price</td>
	 <td>Total Price</td>
 </th>
 <tr>
	 <td>2005</td>
	 <td>Moulin Touchais Coteaux du Layon</td>
	 <td>300x100cl</td>
	 <td>
		 <form>
			 <input type="text" value="3">
			 <button>update</button>
		 </form>
	 </td>
	 <td>£129.17</td>
	 <td>£387.51</td>
 </tr>
</table>

4 个答案:

答案 0 :(得分:2)

th标签排在一排 - 我认为这就是你要找的东西:

<table border="1">
        <tr>
            <th>Vintage</th>
            <th>Product Name</th>
            <th>Size</th>
            <th>Qty</th>
            <th>Per Bottle Price</th>
            <th>Total Price</th>
        </tr>
        <tr>
            <td>2005</td>
            <td>Moulin Touchais Coteaux du Layon</td>
            <td>300x100cl</td>
            <td>
                <form>
                    <input type="text" value="3">
                    <button>update</button>
                </form>
            </td>
            <td>£129.17</td>
            <td>£387.51</td>
        </tr>
    </table>

此外,您还可以添加“thead”和“tbody”标签。

答案 1 :(得分:1)

这部分错了:

        <th>
            <td>Vintage</td>
            <td>Product Name</td>
            <td>Size</td>
            <td>Qty</td>
            <td>Per Bottle Price</td>
            <td>Total Price</td>
        </th>

<th>标记是标题单元格<td>标记是数据单元格),而不是级别元素(<tr>是表格行元素):

        <table>
        <!-- One header row -->
        <tr>
            <th>Vintage</th>
            <th>Product Name</th>
            <th>Size</th>
            ...
        </tr>

        <!-- Then one or more Data rows -->
        <tr>
            <td>2005</td>
            <td>Moulin Touchais Coteaux du Layon</td>
            <td>Size</td>
            ...
        </tr>
        </table>

答案 2 :(得分:0)

<th>替换为<tr>,将<td>替换为<th>

<table>
            <tr>
                <th>Vintage</th>
                <th>Product Name</th>
                <th>Size</th>
                <th>Qty</th>
                <th>Per Bottle Price</th>
                <th>Total Price</th>
            </tr>
            <tr>
                <td>2005</td>
                <td>Moulin Touchais Coteaux du Layon</td>
                <td>300x100cl</td>
                <td>
                    <form>
                        <input type="text" value="3">
                        <button>update</button>
                    </form>
                </td>
                <td>£129.17</td>
                <td>£387.51</td>
            </tr>
        </table>

答案 3 :(得分:0)

替换

<th>
    <td>Vintage</td>
    <td>Product Name</td>
    <td>Size</td>
    <td>Qty</td>
    <td>Per Bottle Price</td>
    <td>Total Price</td>
</th>

<tr>
    <td>Vintage</td>
    <td>Product Name</td>
    <td>Size</td>
    <td>Qty</td>
    <td>Per Bottle Price</td>
    <td>Total Price</td>
</tr>