What is the use of the from tag in html

青灯夜游
Release: 2022-09-15 17:36:13
Original
7604 people have browsed it

In HTML, the from tag is used to create an HTML form (form field) for user input to collect and transfer user information. All content in the form will be submitted to the server; the syntax "Form control". A form can contain one or more form elements, such as input, select, and textarea.

What is the use of the from tag in html

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

html5 form tag

Function: The form tag is used to create an HTML form (form field) for user input to realize the collection and delivery of user information. In the form All content will be submitted to the server.

The form form field can contain various interactive controls - control labels (text fields, check boxes, radio boxes, submit buttons, etc.), such as , , < ; select>, and other tags.

Tag syntax format

<form action="提交地址" method="提交方式" name="表单名称">
  各种表单控件
</form>
Copy after login
  • name: Just name the form, used for js technology.

  • action: Set which file the form data is submitted to, used for back-end technology (such as php) to accept and process the data

  • method : Set the data submission method, which is used to select the appropriate submission (transmission) method according to different data requirements

methodThe four commonly used submission methods:

get    		一般用来查询信息
post		一般用来新增信息
put      	一般用来修改信息
delete		一般用来删除信息
Copy after login

The difference between post and get:

  • Data submission method, get can see the submitted data URL, but post cannot see it

  • get is generally used For submitting a small amount of data, post is used to submit a large amount of data.

  • get can submit up to 1K data. Post has no limit in theory.

  • get can submit data In the browser history, security is not good

A complete form contains three basic components:Form tag, form field, form button.

1. Form tag

refers to the form tag itself, which is an area containing form elements, using the definition

2. Form field

is used to collect each item of user input in the tag. It is usually defined by the input tag. There are different types of input tags, corresponding to different user data. (For example: text field, drop-down list, radio button, check box, etc.)

3. Form button

is used to submit all the information in the form to the server

*表单域和表单按钮都属于表单元素。
Copy after login

Single line text box<input type="text" >The default value is type="text"

Password box<input type="password"/&gt ; 

Radio button<input type="radio" name=""/>

Check box<input type ="checkbox"/>

Hidden field<input type="hidden"/>

File upload<input type ="file"/>

Drop-down box<select>Label

Multi-line text<textarea></textarea>

Submit button<input type="submit"/>

Normal button<input type="button"/>

Reset button<input type="reset"/>

Control label:

input tag

  • The meaning of input
  • <input />The tag is a single tag
  • type attribute sets different attribute values ​​to specify different control types
  • In addition to the type attribute, there are other attributes

type="text" For the ordinary input box, the value is the value inside. The name and id will be used when writing js.

    <form action="url地址" method="提交方式" name="表单名称">
        <input type="text" name="" id="" value="你好">
    </form>
Copy after login

What is the use of the from tag in html

input tag Some attributes:

The checked attribute is only available for radio buttons and check boxes

属性属性值描述
typeText单行文本输入框

Password密码输入框

Radio单选按钮

Checkbox复选框

Button普通按钮

Submit提交按钮

Reset重置按钮

Image图像形式的提交按钮

File文本域
name
空间的名称
value
input控件中的默认文本值
size
input控件在页面中的显示宽度
checked
定义选择空间默认被选中的项
Maxlength
控件允许输入的最多字符数

密码框

<input type="password" name="" id="" value="">
Copy after login

What is the use of the from tag in html

单选框

name相同的单选框智能选择一个

        男 <input type="radio" name="gender" id="" value=""> 
        女 <input type="radio" name="gender" id="" value="">
Copy after login

What is the use of the from tag in html

复选框

多选框可以选取多个

        爱好: <br> 
        抽烟<input type="checkbox" name="hobby" id="" value=""> 
        喝酒<input type="checkbox" name="hobby" id="" value=""> 
        烫头<input type="checkbox" name="hobby" id="" value="">
Copy after login

按钮

普通按钮可以根据需求来用js添加功能

提交按钮会把输入的表单信息提交到form表单的action地址

重置按钮会把表单信息重置为默认

    <form action="url地址" method="提交方式" name="表单名称">
        <input type="button" name="" id="" value="我是一个普通按钮">
        <input type="submit" name="" id="" value="我是一个提交按钮">
        <input type="reset" name="" id="" value="我是一个重置按钮">
    </form>
Copy after login

What is the use of the from tag in html

下拉框标签

下拉框标签有点特殊,不是input的属性而是一个单独的标签

        <select name="省市区" id="">
            <option value="">山东</option>
            <option value="">北京</option>
            <option value="">江苏</option>
            <option value="">深圳</option>
            <option value="">上海</option>
        </select>
Copy after login

What is the use of the from tag in html

(学习视频分享:web前端入门

The above is the detailed content of What is the use of the from tag in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template