国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > HTML > 正文

HTML5表單相關元素和屬性

2020-03-24 16:37:34
字體:
供稿:網(wǎng)友
這篇文章主要介紹了關于HTML5表單相關元素和屬性,有著一定的參考價值,現(xiàn)在分享給大家,有需要的朋友可以參考一下

form :

可以指定id、style、html' target='_blank'>class等核心屬性,還可以指定onclick事件屬性。除此之外,還可以指定如下幾個屬性。

action:指定表單提交的URL或URI。

method:指定請求方式,一般為get或post。

enctype:指定表單內(nèi)容進行編碼所使用的字符集。

name:指定表單的唯一名稱,一般與id的屬性值一致。

target:指定使用哪種方式打開目標URL。

enctype屬性用于指定表單數(shù)據(jù)的編碼方式,該屬性有三個屬性值:

application/x-www-form-urlencoded:這是默認的編碼方式,它只處理表單控件里面的value屬性值,采用這種編碼方式的表單會將表單控件的值處理成URL編碼方式。

multipart/form-data:這種編碼方式會以二進制的方式處理表單數(shù)據(jù),這種編碼方式會將文件域指定文件的內(nèi)容封裝到請求參數(shù)里。

text/plain:當表單的action屬性值為mailto:URL的形式時使用這種編碼方式適用于直接通過表單發(fā)送郵件的方式。

關于表單控件轉(zhuǎn)換成請求參數(shù)的規(guī)則如下:

每個有name屬性的表單控件對應一個請求參數(shù),沒有name屬性的表單控件不會生成請求參數(shù)。

如果多個表單控件有相同的name屬性,則多個表單控件只生成一個請求參數(shù),只是該參數(shù)有多個值。

表單控件的name屬性指定請求參數(shù)名,而value屬性指定請求參數(shù)值。

如果某個表單控件設置了disabled或disabled= disabled 屬性,則該表單控件不再生成請求參數(shù)。

input :

單行文本框:指定 input/ 元素的type屬性為text。

密碼文本框:指定 input/ 元素的type屬性為password。

隱藏域:指定 input/ 元素的type屬性為hidden。

單選框:指定 input/ 元素的type屬性為radio。

復選框:指定 input/ 元素的type屬性為checkbox。

圖像域:指定 input/ 元素的type屬性為image。

文件上傳域:指定 input/ 元素的type屬性為file。

提交、重置、無動作按鈕:分別指定 input/ 元素的type屬性為submit、reset或button即可。

input/ 元素可以指定id,style,class等核心屬性,也可以指定onclick等事件屬性,還可以指定onfocus、onblur等焦點事件屬性。除此之外還可以指定如下屬性:

checked:設置單選框,復選框默認是否選中。

disabled:表示該元素被禁用,當type= hidden 時不能指定該屬性。

maxlength:指定輸入框允許輸入的最大字符數(shù)。

readonly:指定文本框的內(nèi)容不允許修改。

size:指定該元素的寬度,當type= hidden 時不能指定該屬性。

src:指定圖像域所顯示圖像的URL,只有當type= image 時才可以指定該屬性。

 !DOCTYPE html  html lang= en  head  meta http-equiv= Content-Type content= text/html;charset=GBK /  title getForm /title  /head  body  form action= http://www.crazyit.org method= get  單行文本框: input id= username name= username type= text readonly= readonly / br/  密碼框: input id= password name= password type= password / br/  隱藏域: input id= hidden name= hidden type= hidden / br/  第一組單選框: br/  input id= color name= color type= radio value= red /  input id= color2 name= color type= radio value= green /  input id= color3 name= color type= radio value= blue / br/  第二個單選框: br/  input id= gender name= gender type= radio value= male /  input id= gender2 name= gender type= radio value= female br/  兩個復選框: br/  input id= website name= website type= checkbox value= leegang.org /  input id= website2 name= website type= checkbox value= crazyit.org / br/  文件上傳域: input id= file name= file type= file / br/  圖像域: input type= image src= img/wjc.gif alt= 瘋狂Java聯(lián)盟 / br/  下面是四個按鈕: br/  input id= ok name= ok type= submit value= 提交 /  input id= dis name= dis type= submit value= 提交 disabled= disabled /  input id= cancle name= cancle type= reset value= 重填 /  input id= no name= no type= button value= 無動作 /  /form  /body  /html 

label/ :

讓標簽和表單控件關聯(lián)有兩種方式:

隱式使用for屬性:for屬性為所關聯(lián)表單控件的id屬性值。(推薦使用)

顯示關聯(lián):將普通文本、表單控件一起放在 label/ 元素內(nèi)部即可。

 form action= http://www.crazyit.org method= get  label for= username 單行文本框: /label  input id= username name= username type= text / br/  label 密碼框: input id= password name= password type= password / /label br/  input id= ok type= submit value= 登錄瘋狂Java聯(lián)盟 /  /form 

button/ :

內(nèi)部可以包含普通文本、文本格式化標簽、圖像等內(nèi)容,功能比input按鈕更豐富。

button/ 元素可以指定id、style、class等核心屬性,還可以指定onclick等事件響應屬性。除此之外還可以指定如下屬性:

disabled:是否禁用按鈕。

name:指定按鈕唯一的名稱。

type:指定該按鈕屬于哪種按鈕,屬性值只能為button、reset或submit。

value:指定該按鈕的初始值。

 form action= http://www.crazyit.org method= get  button type= button b 提交 /b /button br/  button type= submit img src= images/wjc.gif alt= crazyit.org / /button br/  /form 

select/ :

可以指定id、style、class等核心屬性,該元素僅可以指定onchange事件屬性。除此之外還可以指定如下屬性:

disabled:設置禁用該列表框和下拉菜單。

multiple:設置多選。

size:指定該列表框可以同時顯示多個列表項。

select/ 元素里,只能包含如下兩種元素:

option/ :用來定義列表項和菜單項。

optgroup/ :用來定義列表項和菜單項組,該元素只能包含 option/ 子元素。

textarea/ :

textarea/ 元素可以指定id、style、class等核心屬性,還可以指定onclick、onselect、onchange事件屬性。除此之外,該元素也可以指定如下幾個屬性:

cols:指定文本域的寬度。

rows:指定文本域的高度。

disabled:禁用該文本域。

readonly:指定文本只讀。

相關推薦:

HTML表單相關知識點介紹

HTML5表單屬性教程實例

以上就是HTML5表單相關元素和屬性的詳細內(nèi)容,html教程

鄭重聲明:本文版權歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 元氏县| 南溪县| 宝应县| 沁阳市| 香格里拉县| 江西省| 新龙县| 寿阳县| 巨野县| 鄂州市| 潢川县| 公安县| 明光市| 南宁市| 黎平县| 双峰县| 金溪县| 玉屏| 若尔盖县| 突泉县| 林周县| 曲阳县| 崇左市| 浪卡子县| 常宁市| 峨边| 新绛县| 勃利县| 惠来县| 临洮县| 清水河县| 桐柏县| 九寨沟县| 洪洞县| 友谊县| 通辽市| 建宁县| 环江| 湄潭县| 乾安县| 义马市|