搜尋
首頁web前端html教學HTML 表單輸入類型

HTML 表單輸入類型

Sep 04, 2024 pm 04:53 PM
htmlhtml5HTML TutorialHTML PropertiesHTML 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
HTML的目的:啟用Web瀏覽器可以顯示內容HTML的目的:啟用Web瀏覽器可以顯示內容May 03, 2025 am 12:03 AM

HTML的核心目的在於讓瀏覽器理解並展示網頁內容。 1.HTML通過標籤定義網頁結構和內容,如、到、等。 2.HTML5增強了多媒體支持,引入了和標籤。 3.HTML提供了表單元素,支持用戶交互。 4.優化HTML代碼可提升網頁性能,如減少HTTP請求和壓縮HTML。

為什麼HTML標籤對Web開發很重要?為什麼HTML標籤對Web開發很重要?May 02, 2025 am 12:03 AM

htmltagsareessentialforwebdevelopmentastheyandendenhancewebpages.1)semantictagsimproveaccessibilityandseo.2)semanteLayOut,語義和互動性。 3)poseriblesibilityandseoandseo.3)poseriblesoftagscanoftagscanoftagscanoptagscanoptimizeperefeneandimizeanDenSuroceRecRoscRoss-BrowserCrowserCercerComercompatibility。

說明將一致的編碼樣式用於HTML標籤和屬性的重要性。說明將一致的編碼樣式用於HTML標籤和屬性的重要性。May 01, 2025 am 12:01 AM

一致的HTML編碼風格很重要,因為它提高了代碼的可讀性、可維護性和效率。 1)使用小寫標籤和屬性,2)保持一致的縮進,3)選擇並堅持使用單引號或雙引號,4)避免在項目中混合使用不同風格,5)利用自動化工具如Prettier或ESLint來確保風格的一致性。

如何在 Bootstrap 4 中實現多項目輪播?如何在 Bootstrap 4 中實現多項目輪播?Apr 30, 2025 pm 03:24 PM

在Bootstrap4中實現多項目輪播的解決方案在Bootstrap4中實現多項目輪播並不是一件簡單的事情。雖然Bootstrap...

deepseek官網是如何實現鼠標滾動事件穿透效果的?deepseek官網是如何實現鼠標滾動事件穿透效果的?Apr 30, 2025 pm 03:21 PM

如何實現鼠標滾動事件穿透效果?在我們瀏覽網頁時,經常會遇到一些特別的交互設計。比如在deepseek官網上,�...

HTML 視頻的播放控件樣式怎麼修改HTML 視頻的播放控件樣式怎麼修改Apr 30, 2025 pm 03:18 PM

無法直接通過CSS修改HTML視頻的默認播放控件樣式。 1.使用JavaScript創建自定義控件。 2.通過CSS美化這些控件。 3.考慮兼容性、用戶體驗和性能,使用庫如Video.js或Plyr可簡化過程。

在手機上使用原生select會帶來哪些問題?在手機上使用原生select會帶來哪些問題?Apr 30, 2025 pm 03:15 PM

在手機上使用原生select的潛在問題在開發移動端應用時,我們常常會遇到選擇框的需求。通常情況下,開發者傾...

在手機上使用原生select的弊端是什麼?在手機上使用原生select的弊端是什麼?Apr 30, 2025 pm 03:12 PM

在手機上使用原生select的弊端是什麼?在移動設備上開發應用時,選擇合適的UI組件是非常重要的。許多開發者�...

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

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

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。