码迷,mamicode.com
首页 > Web开发 > 详细

HTML定义表格

时间:2017-12-21 12:03:36      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:post   text   html   结果   nbsp   color   ble   float   标签   

<table>标签用于定义表格,每个表格由<table>标签开始,每个表格行由<tr>标签开始,每个表格数据由<td>标签开始

<html>
<body>

<table border="1">    # <table> 标签用于定义表格,一对 <table>...</table> 就是一个表格,border 属性用于定义边框
  <tr>                # <tr> 标签用于定义行,一对 <tr>...</tr> 就是一行,可以在 <table>...</table> 中定义多个 <tr>...</tr> ,即定义多行
    <td>Hello</td>    # <td> 标签用于定义列,一对 <td>...</td> 就是一列,<td>...</td> 之间就是一个数据,这里定义了两个 <td> ,则表明这一行有两列
    <td>World</td>
  </tr>
</table>

</body>
</html>

结果:

Hello World

 

 

定义三行两列:

<html>
<body>

<table border="1">
<caption>我的标题</caption>    # <caption> 标签可以用于定义表格的标题
<tr> <th>姓名</td> # <th> 可用于定义表头,表头的字体会加粗 <th>年龄</td> </tr> <tr> <td>张三</td> <td>18</td> </tr> <tr> <td>李四</td> <td>23</td> </tr> </table> </body> </html>

结果:

               我的标题

姓名 年龄
张三 18
李四 23

 

 

 

 

 

 

    

HTML定义表格

标签:post   text   html   结果   nbsp   color   ble   float   标签   

原文地址:http://www.cnblogs.com/pzk7788/p/8078675.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!