• 首页
  • css3教程
  • html5教程
  • jQuery手册
  • php7教程
  • MySQL手册
  • apache手册
  • <tr>

    HTML <tr>元素定义表格中的行。它们可以是<td>和<th>元素的组合。

    浏览器支持

    所有浏览器都支持<tr>

    示例

    <table>
      <tr>
        <td>cell a</td>
        <td>cell b</td>
      </tr>
    </table>
    
    内容分类None
    允许的内容零个或多个<td>or<th>元素,或它们的混合
    标签省略开始标记是必填项。如果该<tr>元素紧随其后<tr>,或者父表组(或)元素不再具有任何内容<thead>,则可以省略End标记<tbody><tfoot>
    允许的父元素<table>,<thead>,<tbody>or<tfoot>
    允许的ARIA角色任意
    DOM接口HTMLTableRowElement

    属性

    表格标签支持全局特性。还有一些过期的特性,你应该避免使用它们,但是可以了解它们,会在你阅读旧代码的时候有所帮助。

    • alignTHML5中废弃,THML5中废弃
    • This enumerated attribute specifies how horizontal alignment of each cell content will be handled. Possible values are:
      • left, aligning the content to the left of the cells
      • center, centering the content in the cells
      • right, aligning the content to the right of the cells
      • justify, widening the spaces in the textual content so that the content is justified in the cells
      • char, aligning the textual content on a special character with a minimal offset, defined by thecharandcharoffattributes未实现(查看bug2212)

      If this attribute is not set, the parent node's value is inherited.

      THML5中废弃。此功能已过时。尽量避免使用它。
    • charTHML5中废弃,THML5中废弃
    • This attribute is used to set the character to align the cells in a column on. Typical values for this include a period(.)when attempting to align numbers or monetary values.Ifalignis not set tochar, this attribute is ignored.
      THML5中废弃。此功能已过时。尽量避免使用它。
    • valignTHML5中废弃,THML5中废弃
    • This attribute specifies the vertical alignment of the text within each row of cells of the table header. Possible values for this attribute are:
      • baseline, which will put the text as close to the bottom of the cell as it is possible, but align it on thebaselineof the characters instead of the bottom of them. If characters are all of the size, this has the same effect asbottom.
      • bottom, which will put the text as close to the bottom of the cell as it is possible;
      • middle, which will center the text in the cell;
      • andtop, which will put the text as close to the top of the cell as it is possible.
      Note:Do not use this attribute as it is obsolete(and not supported)in the latest standard: instead set the CSSvertical-alignproperty on it.

    定义和用法

    <tr>标签定义表格中的行。

    HTML 4.01 与 HTML 5 之间的差异

    在 HTML 5 中,不支持<tr>标签的任何属性。

    实例

    一个简单的 HTML 表格,包含两列两行:

    <table border="1">
    <tr>
    <th>month</th>
    <th>savings</th>
    </tr>
    <tr>
    <td>january</td>
    <td>$100</td>
    </tr>
    </table>

    上篇:<thead>