search
HomeWeb Front-endHTML TutorialWhat new input types and attributes are added to HTML5?

New types: color, date, datetime, email, month, number, tel, time, url, week, etc.; new attributes: autofocus, form, max, min, pattern, step, list, etc.

What new input types and attributes are added to HTML5?

(Recommended tutorial: html tutorial)

New input types and their attributes in HTML5

In HTML4.01, the only input types are text, button, password, submit, radio, checkbox and hidden (hidden field). Some new types have been added to H5, which are more convenient to use, including:

  • color

What new input types and attributes are added to HTML5?
Color pops up when clicked Selector, you can select any color

  • number
    What new input types and attributes are added to HTML5?
    Enter a number within the range, you can manually enter a number out of the range, but you cannot submit

  • tel
    Enter the phone number, only safari supports it

  • email
    It has a built-in detection function. When submitting, it will detect whether it contains the @ symbol, and Are there characters before and after the @ symbol

  • range
    What new input types and attributes are added to HTML5?

  • url
    The entered URL must be http:// at the beginning, and there must be characters after it, otherwise it cannot be submitted

  • date
    You can manually select the date
    What new input types and attributes are added to HTML5?

  • time
    You can manually select the time
    What new input types and attributes are added to HTML5?

  • datetime
    Select the date and time with time zone, ie, firfox and chrome do not support it

  • datetime-local
    What new input types and attributes are added to HTML5?
    Select date and time without time zone

  • month
    What new input types and attributes are added to HTML5?
    and The date type is the same, except that you can only select the month

  • week
    What new input types and attributes are added to HTML5?
    and you can only select the week. This date method is rarely used in China.

  • search

    Define the text field used to enter the search string

Some new common properties :

  • autocomplete
    Optional value on/off, indicating that the browser automatically fills in / does not allow automatic filling based on the content previously entered by the user

  • autofocus
    The input automatically gains focus when the page is loaded

  • form
    It is specified that the input outside the form belongs to one or more forms, and the form attribute points to the id value of the belonging form. , if it belongs to multiple forms, add spaces between the ids

  • list

list points to the referenced datalist (the function is the same as select, but not Displayed on the web page) predefined optional options, such as

<form><input list="mylist"/><datalist id="mylist">
    <option>张三</option>
    <option>李四</option>
    <option>王五</option></datalist></form>

and the performance on the page is (the optional options will be expanded when you click on the right side to expand):
What new input types and attributes are added to HTML5?

- formaction

specifies the URL of the file that handles the input control when the form is submitted. (only for type="submit" and type="image")

- formenctype

Specifies how to encode form data when submitted to the server (only for type="submit" and type= "image").

-formmethod

Define the HTTP method that sends form data to the action URL. (Only suitable for type="submit" and type="image")

- formnovalidate

The formnovalidate attribute overrides the novalidate attribute of the

element.

- formtarget

specifies where to display the name or keyword of the response received after submitting the form. (Only suitable for type="submit" and type="image")

- height

Specifies the height of the element. (Only for type="image")

- min
Specifies the minimum input value, applicable to number, range, date, datetime, datetime-local, month, time

- max
specifies the maximum input value, also applies to number, range, date, datetime, datetime-local, month, time

- multiple
allows multiple values, separated by ","

- required
The items must be filled in, that is, it cannot be empty. If it is empty, it will not be submitted

- pattern

Define verification-related regular rules, note that the format does not need to add "/ /"

- placeholder
Define the prompt content displayed in the input box before the user inputs, usually light gray

- step
Define the step size of the number change, that is, the unit of each change, such as step="5". If the input is not an integer multiple of 5, an incorrect format will be prompted when submitting

- width

The width attribute specifies the width of the element. (Only for type="image")

For more programming-related knowledge, please visit: Programming Learning! !

The above is the detailed content of What new input types and attributes are added to HTML5?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

HTML's Purpose: Enabling Web Browsers to Display ContentHTML's Purpose: Enabling Web Browsers to Display ContentMay 03, 2025 am 12:03 AM

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

Why are HTML tags important for web development?Why are HTML tags important for web development?May 02, 2025 am 12:03 AM

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.