首页 >web前端 >html教程 >HTML 表单输入类型

HTML 表单输入类型

WBOY
WBOY原创
2024-09-04 16:53:54569浏览

; 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