<form action="/signup" method="post">
<p>
<label>Title</label><br>
<label>
<input type="radio" name="title" value="mr">
Mr
</label>
<label>
<input type="radio" name="title" value="mrs">
Mrs
</label>
<label>
<input type="radio" name="title" value="miss">
Miss
</label>
</p>
<p>
<label>First name</label><br>
<input type="text" name="first_name">
</p>
<p>
<label>Last name</label><br>
<input type="text" name="last_name">
</p>
<p>
<label>Email</label><br>
<input type="email" name="email" required>
</p>
<p>
<label>Phone number</label><br>
<input type="tel" name="phone">
</p>
<p>
<label>Password</label><br>
<input type="password" name="password">
</p>
<p>
<label>Country</label><br>
<select>
<option>China</option>
<option>India</option>
<option>United States</option>
<option>Indonesia</option>
<option>Brazil</option>
</select>
</p>
<p>
<label>
<input type="checkbox" value="terms">
I agree to the <a href="/terms">terms and conditions</a>
</label>
</p>
<p>
<button>Sign up</button>
<button type="reset">Reset form</button>
</p>
</form>
新! 我的 44 页电子书“44 分钟内掌握 CSS”已发布! 😃
# form
定义一个带有控件的交互式表单。
示例: 复制
action
定义表单提交时信息发送到的 URL。
"/contact"
您可以使用相对 URL。
"https://htmlreference.cn/contact"
您可以使用绝对 URL。
method
定义提交表单时使用的 HTTP 方法。
"post"
表单信息作为请求体的一部分发送到服务器。
"get"
表单信息作为URL 参数的一部分发送到服务器:/contact?first_name=Alex&last_name=Smith
。
name
发送到服务器时的表单名称。当同一网页上存在多个表单时很有用。
"sign_up_form"
名称值必须在整个网页的上下文中是唯一的。
它只能包含字母数字字符a-z
A-Z
0-9
和一些特殊字符,如-
_
... 但不能包含空格。
autocomplete
确定浏览器是否可以自动完成所有表单的控件。
"off"
浏览器将禁用自动完成功能。但是,可以为每个控件单独覆盖此设置。
"on"
浏览器将启用自动完成功能。但是,可以为每个控件单独覆盖此设置。
尝试在这个输入框中按下“向下”键。它将显示之前输入的电子邮件地址。
target
定义单击的链接将在哪个选项卡或窗口中显示。
"_blank"
在新浏览上下文中打开,通常是新标签页。
"_self"
在当前标签页中打开。
"_parent"
在父浏览上下文中打开,如果没有则为_self
。
"_top"
在顶层浏览上下文中打开,如果没有则为_self
。
enctype
定义发送到服务器的信息的MIME 类型。仅在方法为post
时有效。
"application/x-www-form-urlencoded"
默认值。
默认值。
"text/plain"
用于 HTML5 纯文本。
"multipart/form-data"
使用<input type="file">
元素时需要。
novalidate
告诉浏览器在提交时不要验证表单。
不需要值。