two identical html tables display differently

戏子无情 提交于 2021-02-08 11:26:30

问题


why do these tables display differently?

<table>
  <tbody>
    <tr>
      <td style="width:20%;"><b><u>Date</u></b></td>
      <td style="width:20%;"><b><u>Invested</u></b></td>
      <td style="width:30%;"><b><u>Company (and Round)</u></b></td>
      <td style="width:30%;"><b><u>SPV</u></b></td>
    </tr>
  </tbody>
</table>

<br><br><br>


<table>
  <tbody>
    <tr>
      <td style="width:20%;"><b><u>Date</u></b></td>
      <td style="width:20%;"><b><u>Invested</u></b></td>
      <td style="width:30%;"><b><u>Company (and Round)</u></b></td>
      <td style="width:30%;"><b><u>SPV</u></b></td>
    </tr>
  </tbody>
</table>

回答1:


As I surmised in my comment above, the space in <td style="width:20%;"> is a non-breaking space (U+00A0 : NO-BREAK SPACE [NBSP]) which can render as <tdstyle="width:20%;">. Just delete the sapce between td and style and enter a proper space and you're fine. Character identified via https://www.babelstone.co.uk/Unicode/whatisit.html




回答2:


The difference is here, in the screenshot. In the DOM structure, in this line there is a space, like $nbsp. Perhaps you copied this line from another editor. Use it:

<table>
  <tbody>
    <tr>
      <td style="width:20%;"><b><u>Date</u></b></td>
      <td style="width:20%;"><b><u>Invested</u></b></td>
      <td style="width:30%;"><b><u>Company (and Round)</u></b></td>
      <td style="width:30%;"><b><u>SPV</u></b></td>
    </tr>
  </tbody>
</table>

<br><br><br>

<table>
  <tbody>
    <tr>
      <td style="width:20%;"><b><u>Date</u></b></td>
      <td style="width:20%;"><b><u>Invested</u></b></td>
      <td style="width:30%;"><b><u>Company (and Round)</u></b></td>
      <td style="width:30%;"><b><u>SPV</u></b></td>
    </tr>
  </tbody>
</table>


来源:https://stackoverflow.com/questions/63344138/two-identical-html-tables-display-differently

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!