<form method="傳送方式" action="伺服器檔案">
action :浏覽者輸入的資料被傳送到的地方,比如一個PHP頁面(save.php)。
method : 資料傳送的方式(get/post)。 get用于資訊擷取,是從那個網頁獲得,post是向那個網頁送出資料,其詳細差別見此網址: http://www.cnblogs.com/hyddd/archive/2009/03/31/1426026.html
示例1:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>表單标簽</title>
</head>
<body>
<form method="post" action="save.php">
<label for="username">使用者名:</label>
<input type="text" name="username" id="username" value="" />
<label for="pass">密碼:</label>
<input type="password" name="pass" id="pass" value="" />
<input type="submit" value="确定" name="submit" />
<input type="reset" value="重置" name="reset" />
</form>
</body>
</html>
結果圖,其都在同一行顯示。
·label标簽不會向使用者呈現任何特殊效果,它的作用是為滑鼠使用者改進了可用性。如果你在 label 标簽内點選文本,就會觸發此控件。就是說,當使用者單擊選中該label标簽時,浏覽器就會自動将焦點轉到和标簽相關的表單控件上(就自動選中和該label标簽相關連的表單控件上)。
·
<label for="username">使用者名:</label>
<input type="text" name="username" id="username" value="" />
"for" 屬性可把 label 綁定到另外一個元素。請把 "for" 屬性的值設定為相關元素的 id 屬性的值。
label标簽for裡面的值就是其後input标簽id的值。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>fieldset示例</title>
</head>
<body>
<form method="post" action="submit.html">
<p>
<label for="name">Name:</label>
<input type="text" id="name" name="name" placeholder="Your name" required="required" />
</p>
<p>
<label for="email">Email:</label>
<input type="email" id="email" name="email" placeholder="Your email address" required="required" />
</p>
<p>
<label for="message">Message:</label>
<textarea cols="45" rows="7" id="message" name="message" required placeholder="Write your message here."></textarea>
</p>
<input type="submit" value="Send" />
</form>
</body>
</html>
結果圖如下, <!--加p标簽是為了讓各個表單單獨成block,不至于顯示在同一行-->
轉載于:https://www.cnblogs.com/sunmarvell/p/7257652.html