Web速查-索引

定义

<form> 标签用于为用户输入创建 HTML 表单。用于向服务器传输数据。

表单能够包含 input 元素,比如文本字段、复选框、单选框、提交按钮等等。

表单还可以包含 menus、textarea、fieldset、legend 和 label 元素。

属性

属性 描述
accept-charset charset_list 规定服务器可处理的表单数据字符集。
action URL 规定当提交表单时向何处发送表单数据。
autocomplete on、off 规定是否启用表单的自动完成功能。
enctype application/x-www-form-urlencoded、multipart/form-data、text/plain 规定在发送表单数据之前如何对其进行编码:
  • application/x-www-form-urlencoded在发送前编码所有字符(默认)(空格被编码为“+”,特殊字符被编码为ASCII十六进制字符)
  • multipart/form-data 不对字符编码。在使用包含文件上传控件的表单时,必须使用该值
  • text/plain 空格转换为 “+” 加号,但不对特殊字符编码
method get、post 规定用于发送 form-data 的 HTTP 方法。
name form_name 规定表单的名称。
novalidate novalidate 如果使用该属性,则提交表单时不进行验证。
target _blank、_self、_parent、_top、framename 规定在何处打开 action URL。

实例

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>鱼C-零基础入门学习Web(Html5+Css3)</title>
</head>
<body>
<form action="demo/welcome.php" method="post">
名字:<input type="text" name="name"><br><br>
邮箱:<input type="text" name="email"><br><br>
<button type="submit">提交</button>
</form>
</body>
</html>
名字:

邮箱:

视频讲解