两列html表与组

时间:2016-05-14 08:57:09

标签: javascript html

我希望next to name列除了iphone之外,为什么我的表不能按预期工作?

<table>
  <tbody>
    <tr>
      <td>
        <tr>
          <td>Name:</td>
          <td>iphone</td>
        </tr>
        <tr>
          <td>Price:</td>
          <td>123</td>
        </tr>
        <tr>
          <td>Qty</td>
          <td>1</td>
        </tr>
      </td>

      <td>next to name:</td>
      <td>12345</td>

    </tr>
  </tbody>
</table>

1 个答案:

答案 0 :(得分:1)

您无法在tr内写td。您可以为table

添加<tr>包装器

<table border='1'>
  <tbody>
    <tr>
      <td>
        <table>
        <tr>
          <td>Name:</td>
          <td>iphone</td>
        </tr>
        <tr>
          <td>Price:</td>
          <td>123</td>
        </tr>
        <tr>
          <td>Qty</td>
          <td>1</td>
        </tr>
        </table>
      </td>
      <td>next to name:</td>
      <td>12345</td>
    </tr>
  </tbody>
</table>