search
HomeWeb Front-endH5 TutorialWhat are the new form controls and form attributes in HTML5?

What are the new form controls and form attributes in HTML5?

Mar 11, 2021 am 10:42 AM
html5Attributescontrolform

What are the new form controls and form attributes in HTML5?

HTML5 is the next generation standard of the Internet and a language method for constructing and presenting Internet content. It is considered to be one of the core technologies of the Internet.

HTML5 is the specification of the core language HTML in the Web. The content that users see when browsing the web using any means is originally in HTML format. It is converted into a recognizable format through some technical processing in the browser. Information. HTML5 has made certain improvements on the basis of the previous HTML4.01. Although technical personnel may not put these new technologies into application during the development process, website development technical personnel must be aware of the new features of this technology. understand.

New input form control:

  • email: Email text box, no different from ordinary ones

  • - When the input is not an email address, the verification fails

  • - The keyboard on the mobile terminal will change

  • tel: phone number

  • url: URL of the webpage

  • search: search engine

  • - After entering text under chrome, there will be more A closed

  • ## - Example: Use js to display the current value
  • number: an input box that can only contain numbers
  • - There are two arrows at the end of the input box. The upper arrow is for plus and the lower arrow is for minus.
  • Color: Color Selector
  • - Click to display the color version
  • datetime: Display the complete date
  • - Similar to select selection style
  • datetime-local: Display the complete date Date, excluding time zone
  • time: display time, excluding time zone
  • date: display date {year, month, day}
  • week: display the week {year, month, day, week}
  • mouth: display the month {year, month}
  • ## (Free video tutorial:
  • html video tutorial
  • )

    <form>
      <input type="email" />
      <input type="tel" />
      <input type="url" />
      <input type="search" />
      <!--一个滑块加一根长条 min最小表示数 max最大表示数 step 划一格跳几个数字-->
      <input type="range" min="1" max="10"  step="2"/>  <!---->  <input type="number" />  <input type="color" />
      <input type="submit" />
    </form>

    New form features and functions
  • placeholder: input box prompt information

- Example: Weibo password box prompt

autocomplete
  • - The default is on, turn off the prompt selection off
  • autofocus: Specify the form to obtain the input focus
  • list and datalist: Construct a selection list for the input box
  • - The list value is the id of the datalist tag
  • ## required: This option is required and cannot be empty

  • Pattern: Regular Verification

  • - pattern="\d{1,5}"

  • Formaction defines the submission address in submit

  • <input type="text"
      placeholder="请输入4-16个字符" // 输入框内显示
      autocomplete="off" // 是否记录输入的值
      autofocus // 聚焦
      required // 输入框不能为空
      pattern="\d{1,5}" // 必须输入1到5个数字
     />
    //  required 和 pattern 具有安全隐患 如果在控制台修改input的pattern和required 那么就可以破除校验
    
    // 如果用户在某个页面输入相当多的数据,临时有事需要离开一段时间,此时数据应该保存至草稿箱,那么同一个form表单下,将会有两个不同地址的sumbit提交 ope浏览器已支持 其余浏览器可能不支持
    <form action="https://www.baidu.com">
      <input type="text">
      <input type="submit" value="提交" />
      <input type="submit" value="保存至草稿箱" formaction="http://www.miaov.com"/>
    </form>

    Related recommendations:

    html5 tutorial

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

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete
Mastering Microdata: A Step-by-Step Guide for HTML5Mastering Microdata: A Step-by-Step Guide for HTML5May 14, 2025 am 12:07 AM

MicrodatainHTML5enhancesSEOanduserexperiencebyprovidingstructureddatatosearchengines.1)Useitemscope,itemtype,anditempropattributestomarkupcontentlikeproductsorevents.2)TestmicrodatawithtoolslikeGoogle'sStructuredDataTestingTool.3)ConsiderusingJSON-LD

What's New in HTML5 Forms? Exploring the New Input TypesWhat's New in HTML5 Forms? Exploring the New Input TypesMay 13, 2025 pm 03:45 PM

HTML5introducesnewinputtypesthatenhanceuserexperience,simplifydevelopment,andimproveaccessibility.1)automaticallyvalidatesemailformat.2)optimizesformobilewithanumerickeypad.3)andsimplifydateandtimeinputs,reducingtheneedforcustomsolutions.

Understanding H5: The Meaning and SignificanceUnderstanding H5: The Meaning and SignificanceMay 11, 2025 am 12:19 AM

H5 is HTML5, the fifth version of HTML. HTML5 improves the expressiveness and interactivity of web pages, introduces new features such as semantic tags, multimedia support, offline storage and Canvas drawing, and promotes the development of Web technology.

H5: Accessibility and Web Standards ComplianceH5: Accessibility and Web Standards ComplianceMay 10, 2025 am 12:21 AM

Accessibility and compliance with network standards are essential to the website. 1) Accessibility ensures that all users have equal access to the website, 2) Network standards follow to improve accessibility and consistency of the website, 3) Accessibility requires the use of semantic HTML, keyboard navigation, color contrast and alternative text, 4) Following these principles is not only a moral and legal requirement, but also amplifying user base.

What is the H5 tag in HTML?What is the H5 tag in HTML?May 09, 2025 am 12:11 AM

The H5 tag in HTML is a fifth-level title that is used to tag smaller titles or sub-titles. 1) The H5 tag helps refine content hierarchy and improve readability and SEO. 2) Combined with CSS, you can customize the style to enhance the visual effect. 3) Use H5 tags reasonably to avoid abuse and ensure the logical content structure.

H5 Code: A Beginner's Guide to Web StructureH5 Code: A Beginner's Guide to Web StructureMay 08, 2025 am 12:15 AM

The methods of building a website in HTML5 include: 1. Use semantic tags to define the web page structure, such as, , etc.; 2. Embed multimedia content, use and tags; 3. Apply advanced functions such as form verification and local storage. Through these steps, you can create a modern web page with clear structure and rich features.

H5 Code Structure: Organizing Content for ReadabilityH5 Code Structure: Organizing Content for ReadabilityMay 07, 2025 am 12:06 AM

A reasonable H5 code structure allows the page to stand out among a lot of content. 1) Use semantic labels such as, etc. to organize content to make the structure clear. 2) Control the rendering effect of pages on different devices through CSS layout such as Flexbox or Grid. 3) Implement responsive design to ensure that the page adapts to different screen sizes.

H5 vs. Older HTML Versions: A ComparisonH5 vs. Older HTML Versions: A ComparisonMay 06, 2025 am 12:09 AM

The main differences between HTML5 (H5) and older versions of HTML include: 1) H5 introduces semantic tags, 2) supports multimedia content, and 3) provides offline storage functions. H5 enhances the functionality and expressiveness of web pages through new tags and APIs, such as and tags, improving user experience and SEO effects, but need to pay attention to compatibility issues.

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 Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.