HTML總結(下篇)

上接上篇總結

表單

type屬性

用戶可以通過對type進行設置就可以決定使用那種input表單

用戶名:<input type = "text"/>  //文本輸入框
密碼:<input type = "password"/> //密碼輸入框
確認:<input type = "button"/>  //普通按鈕
type總結

在這裏插入圖片描述

value屬性

設置默認文本值

用戶名:<input type="text" name="username" value="請輸入用戶名">
name屬性

name屬性的作用是給表單命名,以區分不同的表單,其次我們可以很快的從後臺找到該表單。

用戶名:<input type="text" name="自己定義"/>

其中值得一提的時radio屬性與name屬性共同使用
比如說同時有多個radio,我們可以通過給他們命名相同的名字name,這樣就可以多個選其中一個。

用戶名:<input type="radio" name="sex" value=""/>
用戶名:<input type="radio" name="sex" value=""/>

checked屬性可以讓radio有一個默認選中的狀態

用戶名:<input type="radio" name="sex" value="" checked="checked"/>
用戶名:<input type="radio" name="sex" value=""/>
label屬性

作用:label用於綁定表單元素,當點擊label時,與label綁定的表單元素會獲得輸入焦點

綁定元素的兩種方法
1.label直接包括input表單

<label>用戶名:<input type="radio" name="username" value="請輸入用戶名"></label>

2.通過for屬性規定label與那個表單元素綁定

<label for "sex"></label>
<input type="radio" name="sex" id="sex">
select屬性 框架
<select>
	<option>選項1</option>
	<option>選項2</option>
	<option>選項3</option>
</select>

注意:一個 select 中至少有一個 option

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章