1.button:
定义可点击按钮(多数情况下,用于通过JS启动脚本)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>input 表单元素</title>
</head>
<body>
<action="xxx.php" method="get">
<!-- text 文本框 用户可以里面输入任何文字 -->
用户名:<input type="text" name="username" value="请输入用户名" maxlength="6"> <br>
<!-- password 密码框 用户看不见输入的密码 -->
密码:<input type="password" name="pwd" > <br>
<!-- radio 单选按钮 可以实现多选一-->
性别: 男 <input type="radio" name="sex" value="男" checked="checked"> 女 <input type="radio" name="sex" value="女"> <br>
爱好:吃饭 <input type="checkbox" name="hobby" value="吃饭"> 睡觉 <input type="checkbox" name="hobby" value="睡觉" > 打豆豆 <input type="checkbox" name="hobby" value="打豆豆" checked="checked"> <br>
<input type="submit" value="注册">
<input type="reset" value="重新设置">
<!-- 普通按钮 -->
<input type="button" value="获取短息验证码">
</form>
</body>
</html>
运行效果:
2.file:
定义输入字段和“浏览”按钮,供文件上传
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>input 表单元素</title>
</head>
<body>
<action="xxx.php" method="get">
<!-- text 文本框 用户可以里面输入任何文字 -->
用户名:<input type="text" name="username" value="请输入用户名" maxlength="6"> <br>
<!-- password 密码框 用户看不见输入的密码 -->
密码:<input type="password" name="pwd" > <br>
<!-- radio 单选按钮 可以实现多选一-->
性别: 男 <input type="radio" name="sex" value="男" checked="checked"> 女 <input type="radio" name="sex" value="女"> <br>
爱好:吃饭 <input type="checkbox" name="hobby" value="吃饭"> 睡觉 <input type="checkbox" name="hobby" value="睡觉" > 打豆豆 <input type="checkbox" name="hobby" value="打豆豆" checked="checked"> <br>
<input type="submit" value="注册">
<input type="reset" value="重新设置">
<!-- 普通按钮 -->
<input type="button" value="获取短息验证码"> </br>
上传文件 <input type="file">
</form>
</body>
</html>
运行效果:
文件域使用场景 上传文件使用的