Home > Article > Web Front-end > Tutorial on how to use HTML form tags
Forms are the most basic way to interact with user input and server-side data on a Web page. Here we focus on the most basic form content display and take a look at the HTML form form tag usage learning tutorial
In HTML Forms 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
<form> 文本域1:<input type=”text” name=”firstname” /> 文本域2:<input type=”text” name=”lastname” /> </form>
The browser displays as follows:
Radio button
Radio button mostly 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
<form> <input type=”radio” name=”sex” value=”male” /> 男生 <input type=”radio” name=”sex” value=”female” /> 女生 </form>
The display in the browser is:
Checkbox
Checkbox allows the user to check one or more corresponding 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>
The browser displays as follows:
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
<form> <select name=”cars”> <option value=”volvo”>Volvo</option> <option value=”saab”>Saab</option> <option value=”fiat”>Fiat</option> <option value=”audi”>Audi</option> </select> </form>
Browser display:
Submit button
The submit button is a necessary part of every form . After the user has entered the corresponding information, he needs to click the submit button to trigger the action and submit the form values to the next page. When the action attribute in the