2013-03-15 55 views
1

我想制作一个HTML文件,其中包含一个垂直列中的标题和右侧列中的数据。总共只有2列。我已经看过html文档并看到了有关范围的东西,但我不完全确定如何在此上下文中使用它。例如:如何制作一个垂直列中包含标题的HTML表格?

enter image description here

谢谢:)

+0

他们有要成为元素中的标题,还是只想让它们变得大胆? – anataliocs 2013-03-15 04:30:21

回答

5

的HTML是相当简单的,只是一定要使用[scope] attribute指定表的正确方向。

<table> 
    <tbody> 
     <tr> 
      <th scope="row">City</th> 
      <td>$city</td> 
     </tr> 
     <tr> 
      <th scope="row">Latitude</th> 
      <td>$latitude</td> 
     </tr> 
     <tr> 
      <th scope="row">Longitude</th> 
      <td>$longitude</td> 
     </tr> 
     <tr> 
      <th scope="row">Country</th> 
      <td>$country</td> 
     </tr> 
    </tbody> 
</table> 

从文档的属性[scope]

状态表示头单元适用于一些相同的行(多个)在随后的细胞。

1

您可以创建与元素,像这样进行元素的表:

<table> 
<tr> 
    <th scope="row">Category 1</th><td>data1</td>   
</tr> 
<tr> 
    <th scope="row">Category 2</th><td>data2</td>   
</tr> 
<tr> 
    <th scope="row">Category 3</th><td>data3</td>   
</tr> 

这里是它在行动的例子:

vertical headers