整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          HTML 表格及實例

          HTML 表格及實例

          可以使用 HTML 創建表格。

          實例

          表格

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <p>每個表格由 table 標簽開始。</p>

          <p>每個表格行由 tr 標簽開始。</p>

          <p>每個表格數據由 td 標簽開始。</p>

          <h4>一列:</h4>

          <table border="1">

          <tr>

          <td>100</td>

          </tr>

          </table>

          <h4>一行三列:</h4>

          <table border="1">

          <tr>

          <td>100</td>

          <td>200</td>

          <td>300</td>

          </tr>

          </table>

          <h4>兩行三列:</h4>

          <table border="1">

          <tr>

          <td>100</td>

          <td>200</td>

          <td>300</td>

          </tr>

          <tr>

          <td>400</td>

          <td>500</td>

          <td>600</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          這個例子演示如何在 HTML 文檔中創建表格。

          表格邊框

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>帶有普通的邊框:</h4>

          <table border="1">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          <h4>帶有粗的邊框:</h4>

          <table border="8">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          <h4>帶有很粗的邊框:</h4>

          <table border="15">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示各種類型的表格邊框。

          表格

          表格由 <table> 標簽來定義。每個表格均有若干行(由 <tr> 標簽定義),每行被分割為若干單元格(由 <td> 標簽定義)。字母 td 指表格數據(table data),即數據單元格的內容。數據單元格可以包含文本、圖片、列表、段落、表單、水平線、表格等等。

          <table border="1">

          <tr>

          <td>row 1, cell 1</td>

          <td>row 1, cell 2</td>

          </tr>

          <tr>

          <td>row 2, cell 1</td>

          <td>row 2, cell 2</td>

          </tr>

          </table>

          在瀏覽器顯示如下:

          row 1, cell 1 row 1, cell 2

          row 2, cell 1 row 2, cell 2

          表格和邊框屬性

          如果不定義邊框屬性,表格將不顯示邊框。有時這很有用,但是大多數時候,我們希望顯示邊框。

          使用邊框屬性來顯示一個帶有邊框的表格:

          <table border="1">

          <tr>

          <td>Row 1, cell 1</td>

          <td>Row 1, cell 2</td>

          </tr>

          </table>

          表格的表頭

          表格的表頭使用 <th> 標簽進行定義。

          大多數瀏覽器會把表頭顯示為粗體居中的文本:

          <table border="1">

          <tr>

          <th>Heading</th>

          <th>Another Heading</th>

          </tr>

          <tr>

          <td>row 1, cell 1</td>

          <td>row 1, cell 2</td>

          </tr>

          <tr>

          <td>row 2, cell 1</td>

          <td>row 2, cell 2</td>

          </tr>

          </table>

          在瀏覽器顯示如下:

          Heading Another Heading

          row 1, cell 1 row 1, cell 2

          row 2, cell 1 row 2, cell 2

          表格中的空單元格

          在一些瀏覽器中,沒有內容的表格單元顯示得不太好。如果某個單元格是空的(沒有內容),瀏覽器可能無法顯示出這個單元格的邊框。

          <table border="1">

          <tr>

          <td>row 1, cell 1</td>

          <td>row 1, cell 2</td>

          </tr>

          <tr>

          <td></td>

          <td>row 2, cell 2</td>

          </tr>

          </table>

          表格中的空單元格

          注意:這個空的單元格的邊框沒有被顯示出來。為了避免這種情況,在空單元格中添加一個空格占位符,就可以將邊框顯示出來。

          <table border="1">

          <tr>

          <td>row 1, cell 1</td>

          <td>row 1, cell 2</td>

          </tr>

          <tr>

          <td>&nbsp;</td>

          <td>row 2, cell 2</td>

          </tr>

          </table>

          在瀏覽器中顯示如下:

          row 1, cell 1 row 1, cell 2

          row 2, cell 2

          更多實例

          沒有邊框的表格

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>這個表格沒有邊框:</h4>

          <table>

          <tr>

          <td>100</td>

          <td>200</td>

          <td>300</td>

          </tr>

          <tr>

          <td>400</td>

          <td>500</td>

          <td>600</td>

          </tr>

          </table>

          <h4>這個表格也沒有邊框:</h4>

          <table border="0">

          <tr>

          <td>100</td>

          <td>200</td>

          <td>300</td>

          </tr>

          <tr>

          <td>400</td>

          <td>500</td>

          <td>600</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示一個沒有邊框的表格。

          表格中的表頭(Heading)

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>表頭:</h4>

          <table border="1">

          <tr>

          <th>姓名</th>

          <th>電話</th>

          <th>電話</th>

          </tr>

          <tr>

          <td>Bill Gates</td>

          <td>555 77 854</td>

          <td>555 77 855</td>

          </tr>

          </table>

          <h4>垂直的表頭:</h4>

          <table border="1">

          <tr>

          <th>姓名</th>

          <td>Bill Gates</td>

          </tr>

          <tr>

          <th>電話</th>

          <td>555 77 854</td>

          </tr>

          <tr>

          <th>電話</th>

          <td>555 77 855</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何顯示表格表頭。

          空單元格

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <table border="1">

          <tr>

          <td>Some text</td>

          <td>Some text</td>

          </tr>

          <tr>

          <td></td>

          <td>Some text</td>

          </tr>

          </table>

          <p>正如您看到的,其中一個單元沒有邊框。這是因為它是空的。在該單元中插入一個空格后,仍然沒有邊框。</p>

          <p>我們的技巧是在單元中插入一個 no-breaking 空格。</p>

          <p>no-breaking 空格是一個字符實體。如果您不清楚什么是字符實體,請閱讀關于字符實體的章節。</p>

          <p>no-breaking 空格由和號開始 ("&"),然后是字符"nbsp",并以分號結尾(";")。</p>

          </body>

          </html>

          [/demo]

          本例展示如何使用 "&nbsp;" 處理沒有內容的單元格。

          帶有標題的表格

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>這個表格有一個標題,以及粗邊框:</h4>

          <table border="6">

          <caption>我的標題</caption>

          <tr>

          <td>100</td>

          <td>200</td>

          <td>300</td>

          </tr>

          <tr>

          <td>400</td>

          <td>500</td>

          <td>600</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示一個帶標題 (caption) 的表格

          跨行或跨列的表格單元格

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>橫跨兩列的單元格:</h4>

          <table border="1">

          <tr>

          <th>姓名</th>

          <th colspan="2">電話</th>

          </tr>

          <tr>

          <td>Bill Gates</td>

          <td>555 77 854</td>

          <td>555 77 855</td>

          </tr>

          </table>

          <h4>橫跨兩行的單元格:</h4>

          <table border="1">

          <tr>

          <th>姓名</th>

          <td>Bill Gates</td>

          </tr>

          <tr>

          <th rowspan="2">電話</th>

          <td>555 77 854</td>

          </tr>

          <tr>

          <td>555 77 855</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何定義跨行或跨列的表格單元格。

          表格內的標簽

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <table border="1">

          <tr>

          <td>

          <p>這是一個段落。</p>

          <p>這是另一個段落。</p>

          </td>

          <td>這個單元包含一個表格:

          <table border="1">

          <tr>

          <td>A</td>

          <td>B</td>

          </tr>

          <tr>

          <td>C</td>

          <td>D</td>

          </tr>

          </table>

          </td>

          </tr>

          <tr>

          <td>這個單元包含一個列表:

          <ul>

          <li>蘋果</li>

          <li>香蕉</li>

          <li>菠蘿</li>

          </ul>

          </td>

          <td>HELLO</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何顯示在不同的元素內顯示元素。

          單元格邊距(Cell padding)

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>沒有 cellpadding:</h4>

          <table border="1">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          <h4>帶有 cellpadding:</h4>

          <table border="1"

          cellpadding="10">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何使用 Cell padding 來創建單元格內容與其邊框之間的空白。

          單元格間距(Cell spacing)

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>沒有 cellspacing:</h4>

          <table border="1">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          <h4>帶有 cellspacing:</h4>

          <table border="1"

          cellspacing="10">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何使用 Cell spacing 增加單元格之間的距離。

          向表格添加背景顏色或背景圖像

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>背景顏色:</h4>

          <table border="1"

          bgcolor="red">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          <h4>背景圖像:</h4>

          <table border="1"

          background="./imagecopy1234567890/test.gif">

          <tr>

          <td>First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td>Second</td>

          <td>Row</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何向表格添加背景。

          向表格單元添加背景顏色或者背景圖像

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <h4>單元背景:</h4>

          <table border="1">

          <tr>

          <td bgcolor="red">First</td>

          <td>Row</td>

          </tr>

          <tr>

          <td

          background="./imagecopy1234567890/test.gif">

          Second</td>

          <td>Row</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何向一個或者更多表格單元添加背景。

          在表格單元中排列內容

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <table width="400" border="1">

          <tr>

          <th align="left">消費項目....</th>

          <th align="right">一月</th>

          <th align="right">二月</th>

          </tr>

          <tr>

          <td align="left">衣服</td>

          <td align="right">1.10</td>

          <td align="right">.20</td>

          </tr>

          <tr>

          <td align="left">化妝品</td>

          <td align="right">.00</td>

          <td align="right">.45</td>

          </tr>

          <tr>

          <td align="left">食物</td>

          <td align="right">0.40</td>

          <td align="right">0.00</td>

          </tr>

          <tr>

          <th align="left">總計</th>

          <th align="right">01.50</th>

          <th align="right">4.65</th>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何使用 "align" 屬性排列單元格內容,以便創建一個美觀的表格。

          框架(frame)屬性

          [demo]

          <html>

          <head>

          <meta charset="UTF-8">

          </head>

          <body>

          <p><b>注釋:</b>frame 屬性無法在 Internet Explorer 中正確地顯示。</p>

          <p>Table with frame="box":</p>

          <table frame="box">

          <tr>

          <th>Month</th>

          <th>Savings</th>

          </tr>

          <tr>

          <td>January</td>

          <td>0</td>

          </tr>

          </table>

          <p>Table with frame="above":</p>

          <table frame="above">

          <tr>

          <th>Month</th>

          <th>Savings</th>

          </tr>

          <tr>

          <td>January</td>

          <td>0</td>

          </tr>

          </table>

          <p>Table with frame="below":</p>

          <table frame="below">

          <tr>

          <th>Month</th>

          <th>Savings</th>

          </tr>

          <tr>

          <td>January</td>

          <td>0</td>

          </tr>

          </table>

          <p>Table with frame="hsides":</p>

          <table frame="hsides">

          <tr>

          <th>Month</th>

          <th>Savings</th>

          </tr>

          <tr>

          <td>January</td>

          <td>0</td>

          </tr>

          </table>

          <p>Table with frame="vsides":</p>

          <table frame="vsides">

          <tr>

          <th>Month</th>

          <th>Savings</th>

          </tr>

          <tr>

          <td>January</td>

          <td>0</td>

          </tr>

          </table>

          </body>

          </html>

          [/demo]

          本例演示如何使用 "frame" 屬性來控制圍繞表格的邊框。

          表格標簽

          表格 描述

          <table> 定義表格

          <caption> 定義表格標題。

          <th> 定義表格的表頭。

          <tr> 定義表格的行。

          <td> 定義表格單元。

          <thead> 定義表格的頁眉。

          <tbody> 定義表格的主體。

          <tfoot> 定義表格的頁腳。

          <col> 定義用于表格列的屬性。

          <colgroup> 定義表格列的組。


          么是表單?

          HTML 表單的功能:

          • 常用于登記信息的輸入,或搜集不同類型的用戶輸入。
          • 表單用于向服務器傳輸數據。

          HTML 表單元素:

          表單元素指的是不同類型的 input 元素、復選框、單選按鈕提交按鈕等等。

          <input> 元素元素有很多形態,根據不同的 type 屬性

          <input type="text" name="name" id="name" class="txt"/>

          文本域(Text fields) <input>元素

          <p>請輸入您的姓名:<br /><input type="text" name="name" id="name" class="txt"/></p>
          

          Text fields

          <select>元素、<option>元素

          簡單的帶有預選值的下拉列表,即預選值指預先指定的首選項。

          <p>請選擇你喜歡的顏色:<br />
          <select name="color" id="color">
          <option value="red">紅</option>
          <option value="green">綠</option>
          <option value="blue">藍</option>
          <option value="yellow">黃</option>
          <option value="cyan">青</option>
          <option value="purple">紫</option>
          </select></p>
          

          表單單選按鈕元素: radio元素

          <p>請問你的性別是:<br />
           <input type="radio" name="sex" id="male" value="male" class="rad" />男<br />
           <input type="radio" name="sex" id="female" value="female" class="rad" />女</p>
          

          表單復選框元素 :checkbox元素

          <p>請問你喜歡做些什么:<br />
           <input type="checkbox" name="hobby" id="book" value="book" class="check" />看書 
           <input type="checkbox" name="hobby" id="net" value="net" class="check" />上網 
           <input type="checkbox" name="hobby" id="sleep" value="sleep" class="check" />睡覺</p>
          

          文本域(Textarea)(多行文本輸入控制,在文本域中,可寫入的字符字數不受限制)

          <p>我要留言:<br /> <textarea name="comments" id="comments" cols="30" rows="4" class="textarea"></textarea></p>
          

          表單提交按鈕元素 :submit元素 class類選擇器

          <p><input type="submit" name="btnSubmit" value="Submit" class="btn" /></p>
          

          form自身屬性 : action 、 method

          1,action:表示當前表單中的內容提交給哪個頁面進行處理

          2,method:表示當前表單提交的方式,常見的有get和post方式,默認是get提交

          <form method="post">
           ..........
          </form>
          

          <form method="get"> 使用展現形式:

          <form method="post" > 使用展現形式:




          <form> 的兼容性:

          幾乎所有的瀏覽器都支持<form>表單標簽。



          附一個簡單的表單應用案例:

          基礎信息表單

          HTML代碼:

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <link rel="stylesheet" type="text/css" href="information.css"/>
          <title>基礎信息表單</title>
          </head>
          <body>
          <form method="post">
          <p>請輸入您的姓名:<br /><input type="text" name="name" id="name" class="txt"/></p>
          <p>請選擇你喜歡的顏色:<br />
          <select name="color" id="color">
          <option value="red">紅</option>
          <option value="green">綠</option>
          <option value="blue">藍</option>
          <option value="yellow">黃</option>
          <option value="cyan">青</option>
          <option value="purple">紫</option>
          </select></p>
          <p>請問你的性別是:<br />
           <input type="radio" name="sex" id="male" value="male" class="rad" />男<br />
           <input type="radio" name="sex" id="female" value="female" class="rad" />女</p>
          <p>請問你喜歡做些什么:<br />
           <input type="checkbox" name="hobby" id="book" value="book" class="check" />看書 
           <input type="checkbox" name="hobby" id="net" value="net" class="check" />上網 
           <input type="checkbox" name="hobby" id="sleep" value="sleep" class="check" />睡覺</p>
           
          <p>我要留言:<br /> <textarea name="comments" id="comments" cols="30" rows="4" class="textarea"></textarea></p>
          <p><input type="submit" name="btnSubmit" value="Submit" class="btn" /></p>
           </form>
          </body>
          </html>
          

          對表單形式進行修改的CSS樣式如下:

          @charset "utf-8";
          /* CSS Document */
          form
          {
          	width:250px;
          	height:350px;
          	border:1px dotted #aAAAAA;
          	padding:1px 6px 1px 6px;
          	margin:0px;
          	font:14px Arial, Helvetica, sans-serif;
          }
          input
          {
          	color:#00008b;
          }
          input.txt
          {
          	border:1px inset #00008b;
          	background-color:#ADd8e6;
          }
          input.btn
          {
          	color:#00008b;
          	background-color:#add8e6;
          	border:1px outset #00008b;
          	padding:1px 2px 1px 2px;
          }
          select
          {
          	width:80px;
          	color:#00008b;
          	background-color:#add8e6;
          	border:1px solid #00008b;
          }
          textarea
          {
          	width:200px;
          	height:40px;
          	color:#00008b;
          	background-color:#add8e6;
          	border:1px inset #00008b;
          }
          

          以上知識是我在學習過程中了解到的關于表單的相關知識,我們可以相互交流,學習。

          (文中部分圖片來自網絡,若有侵權,請聯系修正)

          TML 表格實例:

          First NameLast NamePoints
          JillSmith50
          EveJackson94
          JohnDoe80
          AdamJohnson67

          在線實例

          表格

          這個例子演示如何在 HTML 文檔中創建表格。

          HTML 表格

          表格由 <table> 標簽來定義。每個表格均有若干行(由 <tr> 標簽定義),每行被分割為若干單元格(由 <td> 標簽定義)。字母 td 指表格數據(table data),即數據單元格的內容。數據單元格可以包含文本、圖片、列表、段落、表單、水平線、表格等等。

          表格實例

          <table border="1">

          <tr>

          <td>row 1, cell 1</td>

          <td>row 1, cell 2</td>

          </tr>

          <tr>

          <td>row 2, cell 1</td>

          <td>row 2, cell 2</td>

          </tr>

          </table>

          在瀏覽器顯示如下::

          row 1, cell 1row 1, cell 2
          row 2, cell 1row 2, cell 2

          HTML 表格和邊框屬性

          如果不定義邊框屬性,表格將不顯示邊框。有時這很有用,但是大多數時候,我們希望顯示邊框。

          使用邊框屬性來顯示一個帶有邊框的表格:

          <table border="1">

          <tr>

          <td>Row 1, cell 1</td>

          <td>Row 1, cell 2</td>

          </tr>

          </table>

          HTML 表格表頭

          表格的表頭使用 <th> 標簽進行定義。

          大多數瀏覽器會把表頭顯示為粗體居中的文本:

          <table border="1">

          <tr>

          <th>Header 1</th>

          <th>Header 2</th>

          </tr>

          <tr>

          <td>row 1, cell 1</td>

          <td>row 1, cell 2</td>

          </tr>

          <tr>

          <td>row 2, cell 1</td>

          <td>row 2, cell 2</td>

          </tr>

          </table>

          在瀏覽器顯示如下:

          Header 1Header 2
          row 1, cell 1row 1, cell 2
          row 2, cell 1row 2, cell 2

          更多實例

          沒有邊框的表格

          本例演示一個沒有邊框的表格。

          表格中的表頭(Heading)

          本例演示如何顯示表格表頭。

          帶有標題的表格

          本例演示一個帶標題 (caption) 的表格

          跨行或跨列的表格單元格

          本例演示如何定義跨行或跨列的表格單元格。

          表格內的標簽

          本例演示如何顯示在不同的元素內顯示元素。

          單元格邊距(Cell padding)

          本例演示如何使用 Cell padding 來創建單元格內容與其邊框之間的空白。

          單元格間距(Cell spacing)

          本例演示如何使用 Cell spacing 增加單元格之間的距離。

          HTML 表格標簽

          標簽描述
          <table>定義表格
          <th>定義表格的表頭
          <tr>定義表格的行
          <td>定義表格單元
          <caption>定義表格標題
          <colgroup>定義表格列的組
          <col>定義用于表格列的屬性
          <thead>定義表格的頁眉
          <tbody>定義表格的主體
          <tfoot>定義表格的頁腳

          如您還有不明白的可以在下面與我留言或是與我探討QQ群308855039,我們一起飛!


          主站蜘蛛池模板: 亚洲视频在线一区| 性色AV一区二区三区无码| 在线观看国产一区二三区| 三上悠亚精品一区二区久久| 国产在线观看一区精品| 国产自产V一区二区三区C| 国产精品女同一区二区| 日本高清不卡一区| 亚洲愉拍一区二区三区| 国产精品一区二区久久乐下载| 日韩有码一区二区| 国产在线一区二区三区| 91精品一区二区综合在线| 国产一区二区影院| 国模少妇一区二区三区| 无码av人妻一区二区三区四区| 精彩视频一区二区| 人妻无码一区二区三区四区| 国产激情一区二区三区成人91 | 中字幕一区二区三区乱码| 蜜桃传媒一区二区亚洲AV| 一区二区精品在线观看| 无码国产精成人午夜视频一区二区 | 高清无码一区二区在线观看吞精| www一区二区www免费| 亚洲综合无码一区二区| 国产一区二区三区在线看片| 国产精品区一区二区三在线播放 | 成人免费一区二区三区在线观看| 精品伦精品一区二区三区视频 | 亚洲av色香蕉一区二区三区蜜桃| 亚洲国产精品一区二区三区久久| 精品人伦一区二区三区潘金莲| 无码国产亚洲日韩国精品视频一区二区三区| 奇米精品一区二区三区在| 亚洲丶国产丶欧美一区二区三区| AV无码精品一区二区三区宅噜噜| 亚洲一本一道一区二区三区| 国产在线精品一区二区中文| 欧洲精品一区二区三区| 亚洲欧洲一区二区|