Five, HTML form labels

Source: Internet
Author: User
Tags button type ascii hex values

Forms , the primary function of a form control is to collect the user experience, and when a user submits the form, the user's input is submitted as a request parameter to the remote server.
    • 1,form Label
<form>: Creates a form that does not generate a visual interface, but other controls must be placed inside the tag. Common Properties:
Action: This property is required to specify the confirmation button for a stand-alone form when the form is submitted to that address. can be an absolute address or a relative address.
Method: Used to specify what type of request to send when the form is submitted, either get or post, the difference between get and post 2, in my HTTP blogThere is nothing to repeat here.
Enctype: Used to specify the character set used when encoding the contents of a form. By default, the form data is encoded as "application/x-www-form-urlencoded": that is, all characters are encoded before being sent to the server (spaces are converted to "+" plus signs, and special symbols are converted to ASCII hex values)
There are 3 property values for this property:
Application/x-www-form-urlencoded: Encode all characters before sending (default)
Multipart/form-data: Do not encode characters, you must use this value when using a form that contains a file upload control.
Text/plain Spaces are converted to "+" plus signs, but special characters are not encoded.
Name: A unique name for the form, which is consistent with the recommendation and ID.
Target: Which way to open url,_self,_blank,_top,_parent.
One thing to emphasize about this form tag is how the form controls are converted to the corresponding request parameters, with the following rules:
1, each form control with the Name property corresponds to a request parameter, the form control without the Name property does not generate a request parameter, and if more than one form control repeats a Name property value, only one request parameter is generated, except that the parameter has multiple values.
2, the form control's Name property specifies the request parameter name, and value specifies the request parameter value.
3, if a form control has the disabled= "disabled" property set, the form control will no longer generate request parameters.

    • 2,input Label
The <input> element is the most versatile form control, and the following types of input elements are generated by this tag. This tag is an empty label.
1, single-line text box: type= "Text"
2, Password input box: type= "Password"
3, hidden field: type= "hidden"
4, Radio Box: type= "Radio"
5, check box: type= "checkbox"
6, image domain: type= "image"
7, File Upload domain: type= "file"
8, Commit, Reset, no action button: type= "Submit", type= "reset", type= "button"
The <input> element can specify core properties such as Id,style,class, and can also specify event properties such as Onclick,onfocus,onblur, as well as the following:
1,checked to set whether radio and multi-select are selected
2,disabled, which is used to set disable this element
3,maxlength, which specifies the maximum number of characters allowed in a text box
4,readonly, read-only mode, cannot be modified
5,size, specifying the width of the element
6,SRC, image field displays the URL of the image
7,align, the alignment of image fields
The following is a copy of the HTML that contains the above elements:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
    • 3, list box and drop-down menu
<select> for creating list boxes and drop-down menus, which must be used in conjunction with <option>, each <option> represents a list item or a menu item
Often use 2 properties, disabled, to set the list box disabled and drop-down menus.
Multiple: Used to set whether multiple selections.
It is important to note that whether a <select> is generating a list box or a drop-down menu is determined by the above 2 elements. If size or multiple is specified, a list box is generated, otherwise it is a drop-down menu.
<option>: an option. Value indicates the request parameter value, disabled whether this option is disabled, selected, whether this option is selected
<optgroup>: an option group. Label, required, to specify the label for this option group.
The following is a copy of the HTML that contains the above label:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >


    • 4, define text fields using TEXTAREA
<textarea&gt: Used to define a multiline text field in HTML, 2 attributes required, cols and rows, to specify the width and height of the text field. Multi-line Text field is special, in addition to ordinary event properties, he can also specify the Onselect property, which is used to represent the event that the content inside the text field is selected.
As with a single-line text box, the,<textarea> element should also specify the Name property, which will be the name of the request parameter for textarea, and unlike a single-line text box,<textarea> cannot specify the Value property,< The content between textarea></textarea> will be used as the parameter value for the corresponding request parameter.
About this label is often used, in the past when I write a form, a single line of the text box stretched to widen, but we can only enter the time is a line, can not be wrapped, flowing away quickly.
Here is a copy of the HTML that contains this tag:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

    • 5, label definition using label
<label> is used to define labels in form elements that are simply illustrative of other controls that can generate request parameters, and do not inherently produce request parameters, so do not specify Value property values for the <label> element.
On the surface, the,<label> element is just output plain text, in fact his biggest function is that when we click on the <label> generated text, he said the associated form control will automatically get focus.
There are 2 ways to associate a label with a form control:
1, use the For property implicitly: The For property of the settings <label> label points to the ID property value of the associated form control.
2, Explicit association: The normal text, the form control is left inside the <label></label> tag can be. About these 2 ways to use the first, that is, using for to implicitly associate, because the latter may not be compatible under IE.
The following is a copy of the HTML that contains the above label:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
    • 6, use button to define buttons
The <botton> element is used to define a button, which can contain ordinary text, text formatting tags, images, and so on, which is the difference between <button> and <input> buttons.
This label does not use much, the most is in a button to make the image format will be used. Here is a copy of HTML:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >


Five, HTML form labels

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.