个性化阅读
专注于IT技术分析

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标签

属性

特定于标签的属性:

属性 描述
align 左右中心居中对齐字符 它确定表格行中内容的对齐方式。 (HTML5不支持)
bgcolor rgb(x, x, x)#xxxxx color_name 它定义了表格行的背景色。 (HTML5不支持)
char character 它指定内容与字符的对齐方式。 (HTML5不支持)
charoff number 它指定表行内容将从该字符开始对齐的字符数, 并由char属性指定。 (HTML5不支持)
valign 最高中最低基准 它指定表行内容的垂直对齐方式。 (HTML5不支持)

全局属性:

<tr>标记支持HTML中的Global属性。

事件属性:

<tr>标记支持HTML中的Event属性。

支持的浏览器

Element Chrome IE Firefox Opera Safari
<tr> Yes Yes Yes Yes Yes
赞(0)
未经允许不得转载:srcmini » HTML tr标记

评论 抢沙发

评论前必须登录!