HTML 'td' width and height

前端 未结 2 1652
余生分开走
余生分开走 2020-12-08 13:08

The \'height\' and \'width\' are not supported in HTML5. How can I set a td\'s width and height while conforming to the HTML5 standard?

         


        
相关标签:
2条回答
  • 2020-12-08 13:47

    The width attribute of <td> is deprecated in HTML 5.

    Use CSS. e.g.

     <td style="width:100px">
    

    in detail, like this:

    <table >
      <tr>
        <th>Month</th>
        <th>Savings</th>
      </tr>
      <tr>
        <td style="width:70%">January</td>
        <td style="width:30%">$100</td>
      </tr>
      <tr>
        <td>February</td>
        <td>$80</td>
      </tr>
    </table>
    
    0 讨论(0)
  • 2020-12-08 14:11

    Following width worked well in HTML5: -

    <table >
      <tr>
        <th style="min-width:120px">Month</th>
        <th style="min-width:60px">Savings</th>
      </tr>
      <tr>
        <td>January</td>
        <td>$100</td>
      </tr>
      <tr>
        <td>February</td>
        <td>$80</td>
      </tr>
    </table>
    

    Please note that

    • TD tag is without CSS style.
    0 讨论(0)
提交回复
热议问题