; HTML中的标签用于设计Web表单中的交互控件,以接受来自用户端的数据。根据所使用的用户代理和设备,可以使用多种类型的控制小部件和输入数据。 标签是所有 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. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 checkbox Used to define a checkbox allowing users to select/deselect its values. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 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. 登录后复制 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. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 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 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 radio Used to define a radio button and select a single value out of multiple. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 Red Blue Green reset Used to define a button to reset the form values to its defaults. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 submit Used to define a submit button for the form. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 text Used to define a text field in the form. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 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. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 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. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 email Used to define a text field for email which has all the predefined validations done for checking an email. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 date Used to define a date picker for the HTML form. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 number Used to input numbers in the HTML form by displaying a spinner and adding default validation when used in supported browsers. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 range Used to define a range in the HTML form. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 search Used to define single-line text fields for entering search strings. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 tel Used to define a telephone entering field within an HTML form. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 time Used to define a field for entering time in HTML form 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 url Used to define a text field for entering a url in the HTML form with all its validations being performed automatically. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 week Used to define a text field for entering the week-year number and a week number with no time zone. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 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. 登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制登录后复制 属性 以下部分提供了一个表格,列出了所有相关属性以及简要说明。该表后面是更详细地描述每个属性的列表,以及与它们关联的输入类型。下面更详细地定义了大多数或所有输入类型所共有的那些。 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 新的表单输入类型,我们可以增强用户体验,打造面向未来的应用程序,并使开发人员的编码变得更加容易。对这些新表单输入类型的支持非常强大,尤其是在带有键盘的移动设备中。这些输入类型对于可用性而言是安全的,并且还为用户提供了额外的实用程序。