It is used to transmit data to the server to realize the interaction between the user and the web server.
Can contain input series labels, such as text fields, check boxes, single quotes, and submit buttons.
It can also contain labels such as textarea, select, fieldset, and label.
Form attributes
HTML forms are complex parts of HTML elements. They are often combined with scripts, dynamic pages, and data processing functions. Therefore, HTML forms are important for creating dynamic websites.
Forms are generally used to collect user input information.
How a form works: When a visitor browses a webpage with a form, the visitor can fill in the required information and then click a button to submit the information. The information is transmitted to the server over the Internet.
A special program on the server processes the data. If there is a mistake, the system returns the error message and requires that the error be corrected. When the data is complete, the server returns an input information
<Input> tag
Type
Type: text input box password Input box radio single ‑checkbox multiple selection box submit button (need to use with js.) What is the difference between button and submit? File: To submit a file, add the attribute enctype = "multipart/form-data" to the form to upload the file. Note: 1. The request method must be post 2 enctype = "multipart/form-data"
Attribute
Name: Key of the Form submission item. note: The name attribute is the name used to communicate with the server, and the id attribute is the name used by the browser. This attribute is mainly used to facilitate client programming, the value used in css and javascript: the value of the Form submission item. for different input types, the usage of the value attribute is also different: type = "button", "reset", "submit"-defines the text type = "text" displayed on the button ", "password", "hidden"-defines the initial value of the input field type = "checkbox", "radio", "image"-defines the value checked associated with the input: radio and checkbox are selected by default readonly: read-only. text and passworddisabled.
Select tag
<Select> select the label attribute name from the drop-down list: the Key of the Form submission item. size: Number of options. multiple: multiple <optgroup> adds a group to each item. <option> Each attribute selected in the drop-down list: value: the value of the Form submission item. selected: The selected drop-down list is selected by default.
<Textarea> multi-line text box
<Form id = "form1" name = "form1" method = "post" action = ""> <textarea cols = "width" rows = "height" name = "name"> default content </textarea> </form>
<Label> label
Definition: <label> label defines the annotation (TAG) for the input element ).
Note: The 1 label element does not present any special effects to users. 2 <label> The for Attribute Value of the label should be the same as the id attribute value of the related element.
<Form method = "post" action = ""> <label for = "username"> User name </label> <input type = "text" name = "username" id =" username "size =" 20 "/> </form>
<Fieldset> label
Fieldset can group related elements in a form.
<Fieldset> the label packs a part of the Form Content and generates a set of related form fields.
When a group of form elements are placed in the <fieldset> label, the browser displays them in a special way. They may have special boundaries and 3D effects, or you can even create a subform to process these elements.
<Fieldset> the tag does not have a required or unique attribute. <Legend> the label defines the title for the fieldset element.
All global attributes contained
- If disabled HTML5 sets this bool value attribute, its child form control element also inherits this attribute, except for its first Optional legend element, for example, editing is prohibited. this element and its child element do not accept any browser events, such as click or focus events. Generally, the browser will display such elements in gray.
- Form HTML5 specifies the form to which fieldset belongs. The value of this attribute is the same as the ID of the form to which it belongs. The default value is the nearest form.
- Name of the HTML5 Control Element Group
<Fieldset> <legend> log on. </legend> enter the logon information ...... <Input type = "text"> </fieldset>
Front-end learning site
Recommendation
:https://developer.mozilla.org/en-US/