form Tag
<form action="file link" method="http method"> </form
form attributes
| 屬性 | 說明 | 值 |
|---|---|---|
| name | 標題 | |
| label | 表單元件說明標題 | |
| action | 表單要送到哪裡 | |
| method | 發送 form-data 的 HTTP 方法 | post/get |
| target | 規定在何處打開 action URL | _blank(新視窗),_self,_parent,_top |
Note:
- lable
表單的元件說明標題或可使用其特性運用。常和 input(不包含type="hidden"), textarea, button 等等,使用。<label for="emailid">Email</label> <input type="email id="emailid">"
常用加入 for,設定與 input id 做關聯。當點擊 label 時,會帶到相關連的 input 欄位,等於是點了輸入框的意思。
form elements
input:
<input type="****" value="****" inputmode="****">
type HTML:
| type 屬性 | 說明 | Note |
|---|---|---|
| text | 文字欄位 | |
| password | 密碼 | |
| submit | 送出表單給瀏覽器 | value="submit 按鈕名稱" |
| buttom | 表單按鈕 | |
| checkbox | 選取勾選 | |
| radio | 單選 | |
| 電子郵件輸入欄位 | ||
| date | 日期欄位 | |
| range | 數字範圍 | 範圍設定max="最大數值" min="最小數值" |
| hidden | 隱藏欄位 | 使用在要回傳送值給 sever,但不顯示在畫面上時 |
input CSS:
取消 input 預設樣式

background:none; //預設白底背景取消 outline:none; //點選時出現的藍色外框線 border:0px; //取消預設的黑色外框線屬性選取器 - 選取不同的 type 值:
input[type="button"] {.....} input[type="submit"] {.....}
- inputmode: 輸入鍵盤設定
| inputmode 屬性 | 說明 | Note |
|---|---|---|
| none | 無 | 使用在客製化鍵盤時使用 |
| numeric | 數字鍵盤 | PIN 碼 / zip code / 信用卡號 |
| tel | 電話號碼 | 和 numeric 差異:左下多了 # * + 的符號 |
| decimal | 數字鍵盤(浮點數輸入,身高/體重...) | 左下為. |
| 信箱 | 和 type="email"相同 |
|
| search | 搜尋鍵盤 | 和 type="serch差異":多了右下前往的鍵盤 |
textarea:
<textarea rows="列數" cols="行數">text</textarea>
| type 屬性 | 說明 | Note |
|---|---|---|
| name | 欄位名稱 | |
| row | 設定行數 | |
| col | 設定行數 | |
| maxlength / minlength | 最大/最小輸入字數限制 | |
| placeholder | 欄位提示訊息 |
textarea CSS:
- 取消預設 resize:當拖曳右下角小三角形,可以縮放 textarea 大小。
resize:none; - 背景顏色、外框取消:
outline: none; border : 0;
參考資料:


