HTML表单

1.表单使用表单标签 <form> 来设置:

<form>
.
input 元素
.
</form>
2.文本域(Text Fields)

文本域通过<input type="text"> 标签来设定,当用户要在表单中键入字母、数字等内容时,就会用到文本域。

例:

<form>
<input type="text" name="firstname"><br>
<input type="text" name="lastname"><br>
</form>

注:大多数浏览器中,文本域的默认宽度是 20 个字符。

3.密码字段

密码字段通过标签<input type="password"> 来定义:

例:

<form>
密码: <input type="password" name="password">
</form>

4.单选按钮(Radio Buttons)

<input type="radio"> 标签定义了表单单选框选项

例:

<form>
<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" value="female">Female
</form>

5.复选框(Checkboxes)

<input type="checkbox"> 定义了复选框. 用户需要从若干给定的选择中选取一个或若干选项。

例:

<form>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car
</form>
原文地址:https://www.cnblogs.com/zyj3955/p/14138315.html