Home > Web Front-end > HTML Tutorial > HTML form tag usage

HTML form tag usage

小云云
Release: 2018-01-26 11:19:40
Original
6943 people have browsed it

Generally, the tag is used in forms to collect user input information. The input type is determined by type. The most commonly used form tag is the input tag (). Input types are defined by the type attribute (type). Common input types include text fields, radio buttons, check boxes, drop-down menus, etc.

Forms in HTML can be used to collect various types of input information from users. A form is actually an area containing form elements. The input information of various elements in this area will eventually be submitted to the program script through the form. For example, common ones include user login, registration, publishing articles, etc., which are all submitted to dynamic programs for processing through forms. This section mainly talks about forms and form elements. How to submit form information to dynamic programs will be discussed in future programming language lessons.
The area of ​​the form uses the

tag to define the scope of the form. The value of the element in
will be submitted to the corresponding address through this form.
Text field
The text field can provide users with the function of inputting text. The browser will interpret the text field as a rectangular box. The user moves the cursor to the box and clicks. The cursor can be moved into the frame. Users can type letters, numbers, etc. into the form.
The text field is defined by setting the text value for the type attribute in the tag


##XML/HTML Code Copy content to clipboard

  1. ##<

    form>

  2. Text field 1:
  3. <

    input type=”text” name=”firstname” / >

  4. Text field 2:
  5. <

    input type=”text” name=”lastname” />

  6. ##

    form> The browser displays as follows:


201678135308382.png (296×89)Radio button

Radio button in most cases Appears in the options for users to enter information when registering. This type of multi-user only allows users to select one result. The radio button is defined by setting the value of the type attribute to radio in the tag.

<form>
<input type=”radio” name=”sex” value=”male” /> 男生   
<input type=”radio” name=”sex” value=”female” /> 女生   
</form>
Copy after login

  1. The display in the browser is:


201678135342504.png (164×77)Check box

Checkboxes allow users to select one or more options. A common one is to provide users with functions such as remembering their login account when they log in. You can also collect multiple opinions from users on the user survey page. The check box is defined by setting the value of the type attribute to checkbox in the tag

<form>
<input type=”checkbox” name=”val1″ />
前端开拓者不错   
<input type=”checkbox” name=”val2″ />
前端开拓者一般   
</form>
Copy after login

  1. The browser displays as follows:


201678135409883.png (203×92)Drop-down menu

The drop-down menu is similar to the radio selection in information selection, but the drop-down menu can accommodate more information. And the dropdown menu can execute additional scripts after selecting the menu value. The drop-down menu starts with