<!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>Document</title>
</head>
<body>
<form action="">
账号:<input type="text" name="name"><br><br>
密码:<input type="password" name="password"><br><br>
性别:<input type="radio" name="sex" checked id="man">
<label for="man">男</label>
<input type="radio" name="sex">女<br><br>
爱好:<input type="checkbox">跑步
<input type="checkbox">听音乐
<input type="checkbox" checked>打游戏
<input type="checkbox">健身<br><br>
邮箱:<input type="email"><br><br>
手机:<input type="tel"><br><br>
日期:<input type="date"><br><br>
文件:<input type="file"><br><br>
普通按钮:<input type="button" value="普通按钮"><br><br>
提交按钮:<input type="submit" value="提交按钮"><br><br>
重置按钮:<input type="reset" value="重置按钮"><br><br>
选择水果:<select>
<option value="">苹果</option>
<option value="" selected>香蕉</option>
<option value="">橘子</option>
</select><br><br>
你的留言:<textarea cols="30" rows="10"></textarea><br><br>
<button type="button"><a href="http://www.baidu.com">点击去百度</a></button>
<button type="submit"><img src="../第一节:初始HTML/作业01/初识html.png" width="100px"></button>
<button type="reset">重置</button>
</form>
</body>
</html>
一.表单常用使用场景
1.网页顶部的搜索框
2.网页注册和登录
二.表单标签
1.输入框:input
<input type="text" name="name">
2.下拉框:select
<select>
<option value="">苹果</option>
<option value="" selected>香蕉</option>
<option value="">橘子</option>
</select>
3.文本域:textarea
<textarea cols="30" rows="10"></textarea>
4.按钮:button
<button type="reset">重置</button>
5.input标记标签:label
<input type="radio" name="sex" checked id="man">
<label for="man">男</label>
三.表单属性
1.placeholder:设置提示语
2.maxlength/minlength:设置输入内容最大/最小长度
3.required:设置必填项
4.autofocus:设置自动获取焦点
5.checked:设置单选或多选框的默认选中
6.selected:设置下拉选项的默认选中
7.multiple:设置同时可以上传多个文件
8.disabled:设置标签禁用,标签不能被选中,内容不能被修改
9.readonly:设置标签只读,标签可以被选中,但是内容不能修改
四.form标签及属性
form:设置表单范围
属性:
1.action:设置表单提交过后跳转的页面
2.method:设置表单数据传输方式
可选值:
get:将表单数据伴随action的地址显示在地址栏上面,不安全,不能传输敏感数据,
文本或密码有name的时候,数据内容在地址栏显示
post:将表单数据封装在表单内部传输,相对安全
3.autocomplete:设置是否开启自动填充
可选值:
on:默认值,开启自动填充,text必须有name值
off: 关闭自动填充
目录
2.maxlength/minlength:设置输入内容最大/最小长度
8.disabled:设置标签禁用,标签不能被选中,内容不能被修改
9.readonly:设置标签只读,标签可以被选中,但是内容不能修改