Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the relevant elements and attributes of the HTML5 form

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you what the HTML5 form-related elements and attributes are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

:

You can specify core properties such as id, style, class, and you can also specify onclick event properties. In addition, you can specify the following properties.

Action: specifies the URL or URI for the form submission.

Method: specifies the request method, usually get or post.

Enctype: specifies the character set used to encode the contents of the form.

Name: specifies the unique name of the form, which is generally consistent with the property value of id.

Target: specifies which way to open the target URL.

The enctype property, which is used to specify how the form data is encoded, has three property values:

Application/x-www-form-urlencoded: this is the default encoding, which only deals with the value of the value attribute in the form control. A form with this encoding will process the value of the form control as URL encoding.

Multipart/form-data: this encoding processes the form data in a binary way, and encapsulates the contents of the file specified by the file field into the request parameters.

Text/plain: this encoding is suitable for sending mail directly through the form when the action attribute value of the form is in the form of mailto:URL.

The rules for converting form controls to request parameters are as follows:

Each form control with a name attribute corresponds to a request parameter, and a form control without a name attribute does not generate a request parameter.

If multiple form controls have the same name property, multiple form controls generate only one request parameter, except that the parameter has multiple values.

The name property of the form control specifies the request parameter name, while the value property specifies the request parameter value.

If a form control sets the disabled or disabled= "disabled" property, the form control no longer generates request parameters.

:

Single-line text box: specifies that the type attribute of the element is text.

Password text box: specifies that the type attribute of the element is password.

Hidden field: specifies that the type attribute of the element is hidden.

Radio check box: specifies that the type attribute of the element is radio.

Check box: specifies that the type attribute of the element is checkbox.

Image field: specifies that the type attribute of the element is image.

File upload field: specifies that the type attribute of the element is file.

Submit, reset, No Action buttons: specify the type attribute of the element as submit, reset, or button, respectively.

Elements can specify core attributes such as id,style,class, event attributes such as onclick, and focus event attributes such as onfocus, onblur, and so on. In addition, you can specify the following properties:

Checked: sets the checkbox, and the checkbox defaults to whether it is selected or not.

Disabled: indicates that the element is disabled and cannot be specified when type= "hidden".

Maxlength: specifies the maximum number of characters allowed in the input box.

Readonly: specifies that the contents of the text box are not allowed to be modified.

Size: specifies the width of the element, which cannot be specified when type= "hidden".

Src: specifies the URL of the image displayed in the image field, which can be specified only when type= "image".

GetForm single-line text box: password box: hidden field: first group of radio boxes: second box: two check boxes: file upload field: image field: here are four buttons:

:

There are two ways to associate a label with a form control:

The for property is used implicitly: the for property is the value of the id property of the associated form control. (recommended)

Display association: put plain text and form controls inside the element together.

Single-line text box: password box:

:

The interior can contain plain text, text formatting tags, images and other content, with more functions than input buttons.

Elements can specify core attributes such as id, style, class, and event response attributes such as onclick. In addition, you can specify the following properties:

Disabled: whether to disable the button.

Name: specifies the unique name of the button.

Type: specifies what kind of button the button belongs to, and the property value can only be button, reset, or submit.

Value: specifies the initial value of the button.

Submit

crazyit.org

:

You can specify core attributes such as id, style, class, and so on, and this element can only specify onchange event attributes. In addition, you can specify the following properties:

Disabled: the list box and drop-down menus are disabled by setting.

Multiple: set multiple selections.

Size: specifies that the list box can display multiple list items at the same time.

Elements can only contain the following two elements:

Used to define list and menu items

Used to define list items and menu item groups, which can only contain child elements

:

Elements can specify core attributes such as id, style, class, as well as onclick, onselect, onchange event attributes. In addition, the element can also specify the following attributes:

Cols: specifies the width of the text field.

Rows: specifies the height of the text field.

Disabled: disables the text field.

Readonly: specifies that the text is read-only.

The above is all the content of the article "what are the relevant elements and attributes of the HTML5 form?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 285

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report