當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML <tr>用法及代碼示例

HTML <tr> 標簽用於定義表格中的行。 <tr> 標簽可以包含一個或多個 <th> 頭單元格和 <td> 數據單元格來定義單行 HTML 表格。

<tr> 標簽必須是 <table> 元素的直接子元素,也可以是 <thead>、<tbody> 和 <tfoot> 元素的嵌套子元素。

用法

<tr>.......</tr>

以下是關於 HTML <tr> 標簽的一些規範

Display Inline
開始標簽/結束標簽 開始和結束標記
Usage 表格內容

示例

<!DOCTYPE html>
<html>
<head>
    <title>HTML tr tag</title>
    <style>
      table{
      	border-collapse:collapse;
      	margin-left:350px;
      }
      th,td{
      	padding:25px;} 
      th{
      	background-color:#005cb9;}
      td{
      	background-color:#98f5ff;}
    </style>
</head>
<body>
 <h2>Example of tr tag</h2>
 <table border="1">
 	<caption><b>Top Three performers of Winter Olympic Medals</b></caption>
 	<tr>
 	<th>Rank</th>
 	<th>Country</th>
 	<th>Total medals</th>
        </tr>
        <tr>
 	<td>1</td>
 	<td>Norway</td>
 	<td>329</td>
        </tr>
        <tr>
 	<td>2</td>
 	<td>United State</td>
 	<td>282</td>
       </tr>
 	<tr>
 	      <td>3</td>
 	       <td>Germany</td>
 	      <td>228</td>
             </tr>
 </table>
</body>
</html>

輸出:

HTML tr tag

屬性:

Tag-specific 屬性:

屬性 描述
align 正確的
剩下
中央
證明
燒焦
它確定表格行中內容的對齊方式。 (HTML5 不支持)
bgcolor RGB(x,x,x)
#xxxxxx
color_name
它定義了表格行的背景顏色。 (HTML5 不支持)
char character 它指定內容與字符的對齊方式。 (HTML5 不支持)
charoff number 它指定表格行內容將從字符對齊的字符數,由 char 屬性指定。 (HTML5 不支持)
valign 頂部

底部
基線
它指定表格行內容的垂直對齊方式。 (HTML5 不支持)

全局屬性:

<tr> 標簽支持 HTML 中的全局屬性。

事件屬性:

<tr> 標簽支持 HTML 中的 Event 屬性。

支持瀏覽器

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<tr>YesYesYesYesYes




相關用法


注:本文由純淨天空篩選整理自 HTML <tr> tag。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。