HTML Form表单
本页内容
HTML 表单用于收集用户输入。用户输入常被发送到服务器进行处理。
试试看
示例
<html>
<form action="/third/http.php" method="GET">
<label for="fname">姓名:</label><br>
<input type="text" id="fname" name="fname" value="小白"><br>
<label for="age">年龄:</label><br>
<input type="text" id="age" name="age" value="1"><br><br>
<input type="submit" value="提交">
</form>
</html>
<form> 元素
<form>元素用于为用户输入创建 HTML 表单:
示例
<form>
.
form elements
.
</form>
<form>的元素是不同类型输入元素的容器,例如:文本字段、复选框、单选按钮、提交按钮等。
<input> 元素
HTML<input>元素是最常用的表单元素。
一个<input>元素可以通过多种方式显示,具体取决于type 属性。
- <input type="text"> 显示单行文本输入字段
- <input type="radio"> 显示一个单选按钮
- <input type="checkbox"> 显示一个复选框
- <input type="submit"> 显示提交按钮
- <input type="button"> 显示一个可点击按钮
示例
<form action="/third/http.php" method="GET">
<label for="fname">姓名:</label><br>
<input type="text" id="fname" name="fname" value="小白"><br>
<label for="age">性别:</label><br>
<input type="radio" name='gender' value="女">
<input type="radio" name='gender' value="男">
<input type="submit" value="提交">
</form>