溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

HTML各種表單元素模板及寫法分享

發(fā)布時(shí)間:2021-08-31 09:32:26 來(lái)源:億速云 閱讀:220 作者:chen 欄目:web開發(fā)

這篇文章主要介紹“HTML各種表單元素模板及寫法分享”,在日常操作中,相信很多人在HTML各種表單元素模板及寫法分享問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”HTML各種表單元素模板及寫法分享”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

input中有很多屬性type="text"表示文本框;
name是連接前端后端的橋梁
value屬性,包含的默認(rèn)字符串
size寬度
maxlength接受的最多字符數(shù)
placeholder占位符
required必填屬性
比如寫賬號(hào)和密碼框時(shí)可以這么寫:

 賬號(hào): <input type="text" name="username" value="" size="30" maxlength="6" placeholder="手機(jī)\郵箱\用戶名" required="required" /><br>

password為***一般用于密碼

 密碼: <input type="password" src="" size="30" maxlength="6" /><br>

提交按鈕

        <input type="submit" value="登錄" />
        <input type="reset" value="重置" />

單選框
label的兩種用法,點(diǎn)擊文字可以勾選
checked為默認(rèn)選擇項(xiàng)

  性別:<label><input type="radio" name="gender" checked="checked">男</label>
            <input type="radio" name="gender" id="woman"><label for="woman">女</label>

復(fù)選框

  興趣愛好:
            <label><input type="checkbox" name="interest" id="" value="">讀書</label>
            <label><input type="checkbox" name="interest" id="" value="">游泳</label>
            <label><input type="checkbox" name="interest" id="" value="">籃球</label>

列表框
這里用selected為默認(rèn)
size在這里不是列表寬度
multiple多選

   居住地:<select name="city" size="2" multiple="multiple">
            <option value="NJ">南京</option>
            <option value="SH" selected="selected">上海</option>
            <option value="GZ">廣州</option>
            </select>

多行文本域沒有value
rows列數(shù)cols行數(shù)

    簡(jiǎn)介:<textarea name="showText" rows="3" cols="10" placeholder="請(qǐng)輸入您的簡(jiǎn)介"></textarea>

文件域

  照片:<input type="file" name="" id="" value=""  />

表單郵箱

  郵箱:<input type="email" name="email" id="" value="" />

網(wǎng)址 url

  個(gè)人主頁(yè):
            <input type="url" name="" id="" value="" />

數(shù)字,step代表步長(zhǎng)

   請(qǐng)輸入數(shù)字:
            <input type="number" name="" id="" value="" min="1" max="100" step="3" />

滑塊

   <input type="range"/>

搜索

    搜索:<input type="search" name="" id="" value=""/>

普通按鈕

             <input type="button" name="" id="" value="按鈕" />
            <button type="button">按鈕</button>

提交按鈕其他表示方式

       <input type="submit" name="" id="" value="提交按鈕" />
            <button type="submit">提交按鈕</button>
            <input type="image" src=" ../***.png" />

到此,關(guān)于“HTML各種表單元素模板及寫法分享”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI