Home Web Front-end H5 Tutorial Example analysis of new form elements and attributes in HTML5_html5 tutorial skills

Example analysis of new form elements and attributes in HTML5_html5 tutorial skills

May 16, 2016 pm 03:47 PM
html5 Attributes New form elements

This article uses example code to demonstrate the new form elements and attributes of HTML5. The demonstration code includes placeholder attributes, autofocus attributes, list and datalist elements, search type text box, email type text box, number type text box, range type text box, tel type text box, url type text box, as well as date, time type input elements, etc.
The sample code is as follows:


Copy code
The code is as follows:


HTML5 Mobile Web Development Guide




< section>


HTML5 Mobile Web Development Guide





< legend>HTML5 new element--form element


 placeholder attribute: <br> Generally used in text boxes <br> Its main function is When the text box is in an uninput state and the content is empty, the prompt content for the text box <br> Effect: <br> When the text box gains focus, the prompt information is automatically cleared. When the text box loses focus and no content is entered, the prompt information is automatically cleared again. Appears <br> Eliminating the need for traditional text boxes that require the help of onfocel and onblur events <br> (Compatible with most PC browsers and Mobile browsers, it can only be said that technology has indeed progressed) <br> Example: &lt ;input type="text" placeholder="I am a placeholder, used as a reminder"><br> 



< ;pre> autofocus attribute:
The specified control automatically obtains focus. It should be noted that there can only be one control on an HTML page with the changed attribute
Example:



 list and datalist elements: <br> The main function of the list element is to prompt text box input, and the data source of the prompt is provided by datalist <br> Currently, the list and datalist elements are only supported by the Opera browser, and no mobile browser even supports this feature <br> Example: <input type="text" placeholder="I added the list attribute and datalist element, but not many people understand me" list="myDataList"><br> <datalist id="myDataList"><br> <option label="1">I am datalist1</option><br> <option label="2">I am datalist2</option><br> <option label="3"> I am datalist3</option><br> <option label="4">I am datalist4</option><br> </datalist><br> 


 search type text box: <br> A text box mainly used to search for keywords<br> The only difference between this text box and an ordinary text box is that it is browsed in Safari and Chrome Under the browser, the appearance of the text box is rounded <br> Example: <input type="search" placeholder="I am a search type text box"><br> 


 Email type text box: <br> is a text box that can specify email content. It is usually used in the input text box for entering an email address. <br> This type of text box It looks almost the same as an ordinary text box, but it is actually different under the Safari mobile browser <br> The keyboard will display the corresponding keyboard according to the type of text box <br> Example: <input type ="email" placeholder="I am an email type text box"><br> 



 number type text box : <br> is a text box type used for inputting numbers <br> It can be used with min, max, and step attributes <br> Example: <input type="number" value="0" min=" 0" max="10" step="1"><br> 



 range type text box:<br> It is a numerical range input text box type that provides a sliding input method <br> It needs to be used with min, max, range and other attributes <br> Example: <input type="range" value=" 1" min="0" max="100" step="1"><br> 



 tel Type text box: <br> is a type of text box for users to enter phone numbers <br> In mobile browsers, the keyboard of this text box will display the corresponding keyboard according to the type of text box <br> Example: <input type="tel" placeholder="I am a tel type text box"><br> 



< pre> url type text box:
is a type of text box for users to enter Url address
In mobile browsers, the keyboard of this text box will display the corresponding keyboard according to the type of text box.
Example:



 In the HTML5 specification, in addition to new form elements, there are also date and time input elements <br> but these types are not widely supported <br> The details are as follows: <br> Date and time (Including time zone): <br> <input type="datetime"><br> Date and time (excluding time zone): <br> <input type="datetime-local"><br> Time selection Picker text box: <br> <input type="time"><br> Date picker text box: <br> <input type="date"><br> Week number picker text box for year :<br> <input type="week"><br> Month selector text box: <br> <input type="month"><br> 







HTML5 new element--form element




Statement of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles