form標(biāo)簽和table標(biāo)簽

form標(biāo)簽

跳轉(zhuǎn)頁面(HTTP POST請(qǐng)求),和a標(biāo)簽是一對(duì),a標(biāo)簽有的餐素form標(biāo)簽也有。
如果form表單里面沒有提交按鈕,那就無法提交這個(gè)form。

  1. 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>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容