1 表單元素
作用:表示用于獲取影虎輸入的數(shù)據(jù)
(1)form 設(shè)置html表單
<form method="post" action="http://www.haosou.com/">
<button>提交</button>
</form>
屬性
action:表示表單提交的頁面
methd:表示表單的請求方式:有POST 和GET 兩種键畴,默認(rèn)GET
autocomplete:設(shè)置用戶自動(dòng)完成功能
(2)input 用戶輸入數(shù)據(jù)的文本框
<input name="user" type="username">
屬性
type:input 元素的類型
name:定義input 元素的名稱,以便接收到相應(yīng)的值
(3)<label> 添加說明標(biāo)簽
<p><label for="user">用戶名:<input id="user" name="user"></label></p>
(4)<filedset>對表單進(jìn)行編組
<fieldset>...</fieldset>
屬性
name : 設(shè)置分組名稱
<legend> : 設(shè)置分組名稱
<fieldset>
<legend>注冊表單</legend>
<p><label for="user">用戶名:<input id="user" name="user"></label></p>
</fieldset>
(5) <button type="submit"></button> 添加一個(gè)按鈕
屬性
submit 表示按鈕的作用是提交表單涡贱,默認(rèn)
reset 表示按鈕的作用是重置表單
button 表示按鈕為一般性按鈕惹想,沒有任何作用
2 input的類型
type類型
(1)<input type="text">
maxlength : 設(shè)置輸入框的最大字符
size: 文本框?qū)挾?br>
value: 設(shè)置默認(rèn)值
list : 為文本指定提供建議值的datalist元素
placeholder : 輸入密碼的提示
<input list="list" name="friuit" type="text">
<datalist id="list">
<option value="1">評估</option>
</datalist>
(2)<input type="password"> 隱藏字符的密碼框
(3)<input type="checkbox">復(fù)選框,用戶勾選
(4)<input type="radio"> 單選框激挪,只能在幾個(gè)中選一個(gè)
checked : 設(shè)置默認(rèn)選中項(xiàng)
(5)<input type="submit"> 提交按鈕
(6)<input type="reset"> 重置按鈕
(7)<input type="button"> 普通按鈕
(8)<input type="file"> 生成一個(gè)上傳控件
(9)<inout type="img" src="image.jpg"> : 成一個(gè)圖片按鈕,點(diǎn)擊圖片就實(shí)現(xiàn)提交功能垄分,并且傳送了分區(qū)響應(yīng)數(shù)據(jù)。圖片按鈕也提供了一些額外屬性薄湿。
alt : 圖片說明
src: 圖片路徑
(10)<input type="hiddden"> 生成一個(gè)隱藏控件
4 下拉菜單
<select name="fruit">
<optgroup label="果汁">
<option value="1">蘋果</option>
<option value="2">香蕉</option>
<option value="3">梨子</option>
</optgroup>
<optgroup label="水果">
<option value="1">蘋果汁</option>
<option value="2">香蕉汁</option>
<option value="3">梨子汁</option>
</optgroup>
</select>
<optgroup > 下拉菜單分組
屬性
name : 設(shè)定提交時(shí)的名稱
size :設(shè)置下拉列表的高度
multiple :設(shè)置是否可以多選
5 多行文本
<textarea name="content" wrap="hard" rows="6" cols="9"> </textarea>
屬性
rows : 設(shè)置行數(shù)
cols:設(shè)置列數(shù)