HTML 06: 表格(TABLE)標記(TAGS)

來源:互聯網
上載者:User
文章目錄
  • 跨多列的表元 <th colspan=#>
  • 跨多行的表元 <th rowspan=#>
  • <table border=#>
  • <table border width=# height=#>
  • <table border cellspacing=#>
  • <table border cellpadding=#>
  • <tr align=#>
  • <th align=#> #=left, center, right
  • <td align=#>
  • <tr valign=#>
  • <th valign=#> #=top, middle, bottom, baseline
  • <td valign=#>
  • <table align=left>
  • <table align=right>
  • <caption align=#> ... </caption> #=left, center, right
  • <caption valign=#> ... </caption> #=top, bottom
表格(TABLE)標記(TAGS)

 

 

表格的基本文法<table>...</table> - 定義表格
<tr> - 定義表行
<th> - 定義表頭
<td> - 定義表元(表格的具體資料)

帶邊框的表格:

<table border><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>
Food Drink Sweet
A B C

不帶邊框的表格:

<table><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>
Food Drink Sweet
A B C
 

跨多行、多列的表元(Table Span)

跨多列的表元 <th colspan=#>
<table border><tr><th colspan=3> Morning Menu</th><tr><th>Food</th>       <th>Drink</th>  <th>Sweet</th><tr><td>A</td><td>B</td><td>C</td></table>
Morning Menu
Food Drink Sweet
A B C
跨多行的表元 <th rowspan=#>
<table border><tr><th rowspan=3> Morning Menu</th>        <th>Food</th> <td>A</td></tr><tr><th>Drink</th> <td>B</td></tr><tr><th>Sweet</th> <td>C</td></tr></table>
Morning Menu Food A
Drink B
Sweet C
 

表格尺寸設定

<table border=#>

邊框尺寸設定:

<table border=10><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>
Food Drink Sweet
A B C
<table border width=# height=#>

表格尺寸設定:

<table border width=170 height=100><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>
Food Drink Sweet
A B C
<table border cellspacing=#>

表元間隙設定:

<table border cellspacing=10><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>
Food Drink Sweet
A B C
<table border cellpadding=#>

表元內部空白設定:

<table border cellpadding=10><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>
Food Drink Sweet
A B C
 

表格內文字的對齊/布局

<tr align=#> <th align=#> #=left, center, right<td align=#>
<table border width=160><tr>                <th>Food</th><th>Drink</th><th>Sweet</th><tr>                <td align=left>A</td>                <td align=center>B</td>                <td align=right>C</td>  </table>
Food Drink Sweet
A B C
<tr valign=#> <th valign=#> #=top, middle, bottom, baseline<td valign=#>
<table border height=100><tr>                <th>Food</th><th>Drink</th>                <th>Sweet</th><th>Other</th><tr>                <td valign=top>A</td>                <td valign=middle>B</td>                <td valign=bottom>C</td>                <td valign=baseline>D</td></table>
Food Drink Sweet Other
A B C D
 

表格在頁面中的對齊/布局(Floating Table)

<table align=left>
<table align="left" border><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td></table>My favorites...<br>cookies, chocolates, and more.
Food Drink Sweet
A B C

My favorites...
cookies, chocolates, and more.

 

<table align=right>
Food Drink Sweet
A B C

My favorites...
cookies, chocolates, and more.

 
<table vspace=# hspace=#> #=space value
<table align="left" border vspace=20 hspace=30><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td></table>My favorites...<br>cookies, chocolates, and more.
Food Drink Sweet
A B C

My favorites...
cookies, chocolates, and more.

 

表格的標題

<caption align=#> ... </caption> #=left, center, right
<table border><caption align=center>Lunch</caption><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>

Lunch

Food Drink Sweet
A B C
<caption valign=#> ... </caption> #=top, bottom
  • valign=top is default.
<table border><caption valign=bottom>Lunch</caption><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>

Lunch

Food Drink Sweet
A B C

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.