调整html列的正确方法是什么?

Mat*_*lin 4 html css xhtml

简单的问题,我想知道,2011年是什么样的大小html表的正确方法?(当然包含表格数据!)

以下是否还有可行的方法?

<tr>
    <th width="45%">Name</th>
    <th width="10%">Author</th>
    <th width="20%">Description</th>
    <th width="10%">Rating</th>
    <th width="15%">Download</th>
</tr>
Run Code Online (Sandbox Code Playgroud)

或者给每个列一个ID(或类)并用CSS设置其宽度会更好吗?

谢谢您的意见!

Car*_*bés 9

您可以使用colcolgroup来实现此目的.

<table>
  <col class="x"/>
  <col class="y"/>
  <col class="z"/>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

...并将样式应用于类:

col.x {
   ...
}
Run Code Online (Sandbox Code Playgroud)