--- title:
HTML <tr>
元素定义表格中的行。 同一行可同时出现{{HTMLElement("td")}} 和{{HTMLElement("th")}} 元素。
Content categories | None |
---|---|
Permitted content | Zero or more {{HTMLElement("td")}} or {{HTMLElement("th")}} elements, or a mix of them |
Tag omission | Start tag is mandatory. End tag may be omitted if the {{HTMLElement("tr")}} element is immediately followed by a {{HTMLElement("tr")}} element, or if the parent table group ({{HTMLElement("thead")}}, {{HTMLElement("tbody")}} or {{HTMLElement("tfoot")}}) element doesn't have any more content |
Permitted parents | {{HTMLElement("table")}}, {{HTMLElement("thead")}}, {{HTMLElement("tbody")}} or {{HTMLElement("tfoot")}} element |
Permitted ARIA roles | Any |
DOM interface | {{domxref("HTMLTableRowElement")}} |
表格标签支持 全局特性。还有一些过期的特性,你应该避免使用它们,但是可以了解它们,会在你阅读旧代码的时候有所帮助。
left
, 内容在单元格中左对齐center
, 内容在单元格中居中right
, 内容在单元格中右对齐justify
, 增加文本内容之间的空白以伸展这行文本,使得该单元格中的多行文本具有相同的长度。char
, aligning the textual content on a special character with a minimal offset, defined by the {{htmlattrxref("char", "tr")}} and {{htmlattrxref("charoff", "tr")}} attributes {{unimplemented_inline("2212")}}If this attribute is not set, the parent node's value is inherited.
left
, center
, right
or justify
values, use the CSS {{cssxref("text-align")}} property on it.char
value, in CSS3, you can use the value of the {{htmlattrxref("char", "tr")}} as the value of the {{cssxref("text-align")}} property {{unimplemented_inline}}.#RRGGBB
or #RGB
value or a color keyword.
char
, this attribute is ignored.
baseline
, which will put the text as close to the bottom of the cell as it is possible, but align it on the baseline of the characters instead of the bottom of them. If characters are all of the size, this has the same effect as bottom
.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;top
, which will put the text as close to the top of the cell as it is possible.See {{HTMLElement("table")}} for examples on <tr>
.
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG','tables.html#the-tr-element','tr element')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5 W3C','tabular-data.html#the-tr-element','tr element')}} | {{Spec2('HTML5 W3C')}} |
<tr>
element:
{{HTMLRef}}