form標(biāo)簽
跳轉(zhuǎn)頁面(HTTP POST請(qǐng)求),和a標(biāo)簽是一對(duì),a標(biāo)簽有的餐素form標(biāo)簽也有。
如果form表單里面沒有提交按鈕,那就無法提交這個(gè)form。
- input標(biāo)簽
<form action="users" method="post">
<input type="button" value = "提交">
<input type="submit" value = "提交">
<button>提交<button>
</form>
type是button時(shí)只是個(gè)普通按鈕,點(diǎn)擊不能提交;type是submit時(shí)可以提交;如果form里只有一個(gè)按鈕,那button按鈕自動(dòng)升級(jí)為提交按鈕。
喜歡的水果
<input type="checkbox" id="xxx" name="fruit" value="orange">
<label for="xxx">橘子</label>
/*老司機(jī)寫法
<label><input type="checkbox" name="fruit" value="orange">愛我</label>
label標(biāo)簽通過for和input的id關(guān)聯(lián),實(shí)現(xiàn)點(diǎn)擊文字也能實(shí)現(xiàn)勾選的功能。所有需要提交內(nèi)容的input標(biāo)簽都要加上name屬性,否則不會(huì)向服務(wù)器提交該內(nèi)容。向服務(wù)器提交的內(nèi)容是name?value,比如fruit=orange。
<label><input type="radio" name="sex" value="male">男</label>
<label><input type="radio" name="sex" value="female">女</label>
type為radio時(shí),name相同時(shí)是一對(duì)單選框。type為radio和checkbox這種input不輸入內(nèi)容的需要提供value值,告訴服務(wù)器你提交的內(nèi)容,sex=male或者sex=female。value值跟type是password的輸入框內(nèi)輸入的內(nèi)容是同等的。
<select name="city">
<option value="beijing" disabled>北京</option>
<option value="shanghai" selected>上海</option>
<option value="hangzhou">杭州</option>
</select>
disabled默認(rèn)不能選擇,selected默認(rèn)選項(xiàng)。
<textarea name="article" style="resize:none; width: 200px; height: 100px">
多行文本,注意和 type=text的區(qū)別
</textarea>
textarea通過css控制輸入框大小,否則可以自由拉伸。
table標(biāo)簽
<table border=1>
<colgroup>
<col width=100>
<col bgcolor=red width=200>
<col width=100>
<col width=70>
</colgroup>
<thead>
<tr>
<th>項(xiàng)目</th><th>姓名</th><th>班級(jí)</th><th>分?jǐn)?shù)</th>
</tr>
</thead>
<tbody>
<tr>
<th></th><td>小明</td><td>1</td><td>94</td>
</tr>
<tr>
<th></th><td>小紅</td><td>2</td><td>96</td>
</tr>
<tr>
<th>平均分</th><td></td><td></td><td>95</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>總分</th><td></td><td></td><td>190</td>
</tr>
</tfoot>
</table>

<style>
table {
border-collapse: collapse;
}
</style>
