2016-08-12 184 views
-1

該表似乎在<th>部分的開頭處生成一個空的<td><td>單元格。任何想法爲什麼要這樣做以及如何解決它?HTML生成空​​

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

+0

請解釋清楚你試圖做解決什麼問題,什麼它。 –

+0

''元素不能替代''元素,它們替代了'​​'元素。您的HTML無效。 – j08691

回答

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

的個標籤進入連續在內線 - 我覺得這是你在找什麼:

<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」添加標籤。

0

<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> 
0

更換<th>更換

<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>