Form control". A form can contain one or more form elements, such as input, select, and textarea."/> Form control". A form can contain one or more form elements, such as input, select, and textarea.">

Home >Web Front-end >Front-end Q&A >What is the use of the from tag in html

What is the use of the from tag in html

青灯夜游
青灯夜游Original
2022-09-15 17:36:137655browse

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>
  • 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		一般用来删除信息

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

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

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

Password box<input type="password"> 

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</select>

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
  • &lt;input&gt;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.

    
        &lt;input&gt;     

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

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

Password 密码输入框

Radio 单选按钮

Checkbox 复选框

Button 普通按钮

Submit 提交按钮

Reset 重置按钮

Image 图像形式的提交按钮

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

密码框

&lt;input&gt;

What is the use of the from tag in html

单选框

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

        男 &lt;input&gt; 
        女 &lt;input&gt;

What is the use of the from tag in html

复选框

多选框可以选取多个

        爱好: 
          抽烟&lt;input&gt;          喝酒&lt;input&gt;          烫头&lt;input&gt;

按钮

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

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

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

    
        &lt;input&gt;         &lt;input&gt;         &lt;input&gt;     

What is the use of the from tag in html

下拉框标签

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

        <select>
            <option>山东</option>
            <option>北京</option>
            <option>江苏</option>
            <option>深圳</option>
            <option>上海</option>
        </select>

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!

Statement:
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