目錄
HTML 中可用的「輸入」類型清單
List of the types of “input” available in HTML5
屬性
結論 – HTML 表單輸入類型
首頁 web前端 html教學 HTML 表單輸入類型

HTML 表單輸入類型

Sep 04, 2024 pm 04:53 PM
html html5 HTML Tutorial HTML Properties HTML tags

; HTML中的標籤用於設計Web表單中的交互控件,以接受來自用戶端的資料。根據所使用的用戶代理和設備,可以使用多種類型的控制小部件和輸入資料。 標籤是所有 HTML 中使用的最重要的元素之一,因為它具有大量的屬性和輸入類型組合。在本主題中,我們將學習 HTML 表單輸入類型。

HTML 表單輸入類型

標籤是 HTML

的重要元素。元素。 中的「type」屬性標籤可以有多種類型,用於定義資訊字段,例如提供一個文字方塊。 的預設類型是標籤是文字。

HTML 中可用的「輸入」類型清單

Type Description Format Example
button Used to define a push button with the text of the button being the value of the value attribute. HTML 表單輸入類型


checkbox Used to define a checkbox allowing users to select/deselect its values. HTML 表單輸入類型


Cricket
Tennis
Football
file Used to define a file upload feature on the local system with the accept attribute being used to restrict the file types for upload. HTML 表單輸入類型


<input type="file" name="newfile">

hidden Used to hide a control whose value will be submitted on the server. There is an example in the next column, but it’s hidden!
image A graphical submit button — displaying an image defined with the src attribute. The alt attribute displays if the image src is missing. HTML 表單輸入類型


password Used to define a single-line text field whose value is obscured, and it will also alert the user if the site is not secure HTML 表單輸入類型



radio Used to define a radio button and select a single value out of multiple. HTML 表單輸入類型


Red
Blue
Green
reset Used to define a button to reset the form values to its defaults. HTML 表單輸入類型


submit Used to define a submit button for the form. HTML 表單輸入類型


text Used to define a text field in the form. HTML 表單輸入類型



List of the types of “input” available in HTML5

Type Description Format Example
color Used to define the color of the elements in an HTML form. It takes a hexadecimal input. HTML 表單輸入類型


datetime-local Used to define an element for date and time in the HTML form with opening a date picker or numeric wheels for the month, day, and year, when used in supported browsers. HTML 表單輸入類型


email Used to define a text field for email which has all the predefined validations done for checking an email. HTML 表單輸入類型


date Used to define a date picker for the HTML form. HTML 表單輸入類型


number Used to input numbers in the HTML form by displaying a spinner and adding default validation when used in supported browsers. HTML 表單輸入類型


range Used to define a range in the HTML form. HTML 表單輸入類型


search Used to define single-line text fields for entering search strings. HTML 表單輸入類型


tel Used to define a telephone entering field within an HTML form. HTML 表單輸入類型


time Used to define a field for entering time in HTML form HTML 表單輸入類型


url Used to define a text field for entering a url in the HTML form with all its validations being performed automatically.

 

HTML 表單輸入類型


week Used to define a text field for entering the week-year number and a week number with no time zone. HTML 表單輸入類型


datetime Used to define a text field for entering a date and time (hour, minute, second, and fraction of a second) based on the UTC time zone. HTML 表單輸入類型


屬性

以下部分提供了一個表格,列出了所有相關屬性以及簡要說明。該表後面是更詳細地描述每個屬性的列表,以及與它們關聯的輸入類型。下面更詳細地定義了大多數或所有輸入類型所共有的那些。

Attribute Types
1.       accept file
2.       alt image
3.       autocomplete all
4.       autofocus all
5.       capture file
6.       checked radio, checkbox
7.       dirname text, search
8.       disabled all
9.       form all
10.    formaction image, submit
11.    formenctype image, submit
12.    formmethod image, submit
13.    formnovalidate image, submit
14.    formtarget image, submit
15.    height image
16.    list almost all
17.    max numeric types
18.    maxlength password, search, tel, text, url
19.    min numeric types
20.    minlength password, search, tel, text, url
21.    multiple email, file
22.    name all
23.    pattern password, text, tel
24.    placeholder password, search, tel, text, url
25.    readonly almost all
26.    required almost all
27.    size email, password, tel, text
28.    src image
29.    step numeric types
30.    type all
31.    value all
32.    width image

結論 – HTML 表單輸入類型

借助 HTML5 新的表單輸入類型,我們可以增強用戶體驗,打造面向未來的應用程序,並使開發人員的編碼變得更加容易。對這些新表單輸入類型的支援非常強大,尤其是在具有鍵盤的行動裝置中。這些輸入類型對於可用性而言是安全的,並且還為使用者提供了額外的實用程式。

以上是HTML 表單輸入類型的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

Rimworld Odyssey溫度指南和Gravtech
1 個月前 By Jack chen
Rimworld Odyssey如何釣魚
1 個月前 By Jack chen
我可以有兩個支付帳戶嗎?
1 個月前 By 下次还敢
初學者的Rimworld指南:奧德賽
1 個月前 By Jack chen
PHP變量範圍解釋了
3 週前 By 百草

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Laravel 教程
1603
29
PHP教程
1506
276
什麼是HTML5數據屬性? 什麼是HTML5數據屬性? Aug 06, 2025 pm 05:39 PM

HTML5dataattributesarecustom,validHTMLattributesusedtostoreextrainformationinelementsforJavaScriptorCSS.1.Theyaredefinedasdata-*attributes,likedata-user-id="123".2.Theyallowembeddingprivate,customdatadirectlyinmarkupwithoutaffectinglayoutor

HTML ID和類有什麼區別 HTML ID和類有什麼區別 Aug 07, 2025 am 12:03 AM

id必須唯一,每個頁面中一個id只能用於一個元素,而class可重複使用於多個元素,且一個元素可擁有多個class;2.使用id的場景包括:定位單個特定元素、頁面內鏈接錨點、JavaScript通過id操作元素、label與表單元素關聯;使用class的場景包括:對多個元素應用相同樣式或行為、構建可複用UI組件、JavaScript選擇多個元素;3.CSS中通過#id選擇器和.class選擇器分別targeting,JavaScript中getElementById()用於id,getEleme

如何將帆布API用於HTML5中的基本圖? 如何將帆布API用於HTML5中的基本圖? Aug 07, 2025 am 07:15 AM

要使用HTML5CanvasAPI進行基本繪圖,首先在HTML中創建canvas元素並設置寬高屬性,然後通過JavaScript獲取其2D渲染上下文;1.使用fillRect、strokeRect和clearRect繪製和清除矩形;2.通過beginPath、moveTo、lineTo和closePath創建路徑並繪製線條或自定義形狀;3.利用arc方法繪製圓形或弧線;4.使用fillText和strokeText添加填充或描邊文本;5.通過設置fillStyle、strokeStyle、lin

如何在html中的網站標題選項卡中添加圖標 如何在html中的網站標題選項卡中添加圖標 Aug 07, 2025 pm 11:30 PM

要為網站標題欄添加圖標,需在HTML的部分鏈接一個favicon文件,具體步驟如下:1.準備一個16x16或32x32像素的圖標文件,推薦使用favicon.ico命名並放置於網站根目錄,或使用PNG、SVG等現代格式;2.在HTML的中添加鏈接標籤,如,若使用PNG或SVG格式則相應調整type屬性;3.可選地為移動設備添加高分辨率圖標,如AppleTouchIcon,並通過sizes屬性指定不同尺寸;4.遵循最佳實踐,將圖標置於根目錄以確保自動檢測,更新後清除瀏覽器緩存,檢查文件路徑正確性,

HTML5中的可讀性屬性是什麼? HTML5中的可讀性屬性是什麼? Aug 08, 2025 am 11:55 AM

ThereadonlyattributeinHTML5makesforminputsnon-editablewhilestillallowingsubmissionanduserinteraction;1.Itappliestoandelements;2.Itisabooleanattribute,soonly"readonly"needstobepresent;3.Unlike"disabled",itallowsfocusandthedataisinc

如何以HTML5形式創建彩色選擇器? 如何以HTML5形式創建彩色選擇器? Aug 08, 2025 am 03:48 AM

使用type="color"可創建HTML5顏色選擇器,1.使用添加顏色輸入;2.可通過value屬性設置默認顏色值(必須為7字符十六進制格式如#ffffff);3.現代瀏覽器均支持,舊版瀏覽器會回退為文本輸入;4.可結合JavaScript實時預覽顏色變化;5.應添加label標籤以提升可訪問性,必要時可用JavaScript庫提供降級支持,該方法簡單有效且廣泛支持。

工具提示的HTML標題屬性是什麼 工具提示的HTML標題屬性是什麼 Aug 06, 2025 am 10:50 AM

ThetitleattributecreatestooltipsinHTMLbydisplayingitsvalueasasmallpopupwhenusershoveroveranelement.2.ItissupportedacrossmostHTMLelementslikelinks,images,buttons,andinputs,withbrowsersshowingthetooltipautomaticallywithoutrequiringJavaScriptorCSS.3.Whi

HTML5中輸出標籤的目的是什麼? HTML5中輸出標籤的目的是什麼? Aug 06, 2025 pm 04:22 PM

Thetagisusedtodisplaytheresultofacalculationoruseractioninaform,suchasshowingthesumoftwoinputvaluesinrealtime.2.Itprovidessemanticmeaning,indicatingthatthecontentisdynamicoutputratherthanstatictext,whichenhancescodeclarityandaccessibility.3.Theforatt

See all articles