代码之家  ›  专栏  ›  技术社区  ›  David M.

为什么标签内的<br>后需要有文本?

  •  0
  • David M.  · 技术社区  · 7 年前

    <br> 当它位于另一个标记内时进行标记。

    我在做这张桌子 <thead> 有两个 <th> 里面写着: 还有另一个 “姓氏” <br> 插入到 “上一个” 显示第二个 < 在两行中,避免较长的单元格宽度。

    既然 “姓氏” 以两行显示,文本以两行显示 <th> 不要从同一高度开始。

    “名称” <th> 从同一高度开始 <th> .

    • 打字 <th>NAME <br> </th>
    • 打字 <th>NAME <br> .</th> 是否需要换行。

    如果空格位于标记之间,那么它们不应该算作内容吗?因此,激活 <

    <th> 第二行没有不必要的字符,或者不需要使用CSS样式?

    检查html并启发我

    <html>
    
    <body>
      <table border="2px">
        <thead>
          <th>NAME <br> </th>
          <th>LAST<br>NAME</th>
        </thead>
        <tbody>
          <tr>
            <td>John</td>
            <td>Doe</td>
          </tr>
        </tbody>
      </table>
    
      <br>
    
      <table border="2px">
        <thead>
          <th>NAME <br> .</th>
          <th>LAST<br>NAME</th>
        </thead>
        <tbody>
          <tr>
            <td>John</td>
            <td>Doe</td>
          </tr>
        </tbody>
      </table>
    </body>
    
    </html>

    我很好奇 <br>

    2 回复  |  直到 7 年前
        1
  •  0
  •   Maantje    7 年前

    你可以试着放一个 &nbsp; 在他们之间,这应该做什么你正在寻找。

    <th>NAME <br>&nbsp;</th>
    

    <th>NAME <br /> </th>
    
        2
  •  0
  •   jafarbtech    7 年前

    使用其中一个 style="vertical-align:top;" valign="top" 将其顶部对齐

    <html>
    
    <body>
      <table border="2px">
        <thead>
          <th valign="top">NAME</th>
          <th>LAST<br>NAME</th>
        </thead>
        <tbody>
          <tr>
            <td>John</td>
            <td>Doe</td>
          </tr>
        </tbody>
      </table>
    
      <br>
    
      <table border="2px">
        <thead>
          <th style="vertical-align:top;">NAME</th>
          <th>LAST<br>NAME</th>
        </thead>
        <tbody>
          <tr>
            <td>John</td>
            <td>Doe</td>
          </tr>
        </tbody>
      </table>
    </body>
    
    </html>