HTML 重难点
a 标签
1. a 标签属性
- href
- 网址:href=“https://www.google.com" or href=“http://www.google.com" or //google.com
- 路径:href=“/a/b/c.html”
- 伪协议:href=“javascript:alert(1);” (value 要小写,点击会执行 javascript 代码) or javascript:;相对于页面来说,不会有视觉上的刷新
- ID 当某个标签有 id 之后.例 :id=“xx” href=“#xx”.会定位到 id 为 xx
- mailto:href=“mailto:460046653@qq.com” ;
- tel:href=“tel:11 位电话号” ; 点击时会打电话
总结:可跳转到其他页面,可跳转到子页面,可跳转到邮箱、电话.
target
_blank :target 取值为:_blank
空白页面打开
_top :在 iframe src 属性链接的页面里,a 标签 target 设置_top 会在最顶页面打开
_parent:在父级页面打开跳转页面
_self:target 取值为:_blank当前页面打开
window.name:target=“xx” 指定窗口(如果没有会新建一个窗口(在空白页))为打开
iframe.name:指定在 iframe 标签打开页面:当 iframe 属性 name 为:xx。 a 属性 target=“xx” 则会在 iframe 页面中打开跳转页面
download:下载当前页面(浏览器支持度低)
rel=noopener:以后补上。
iframe 标签
主要作用于在页面里,加载一个页面。会有上下关系
table 标签
相关标签
<table> <thead> <tr> <!--table row (代表一行) --> <th></th> <!--table head (表头)--> <th>1</th> <th>2</th> </tr> </thead> <tbody> <tr> <th></th> <td>3</td> <!--table data (表数据)--> <td>4</td> </tr> </tbody> <tfoot></tfoot> </table>
1 | 2 | |
---|---|---|
3 | 4 |
table thead tbody tfoot tr th td
img 标签
作用
发送 get 请求展示一张图片
属性
alt:文字替换(当图片加载失败,会显示文字)
height:设置高度
width:设置宽度
src:设置图片来源
事件
onload:在 js 里,判单是否加载成功
onerror:在 js 里,判断是否加载失败
响应式
max-width:100%; 适应不同的宽高度
form 标签
作用
发送 get 或 post 请求,然后刷新页面
属性
action:把数据发送到页面
autocomplete:自动填充用户名等等
method:使用 get/post 方法提交
target:当提交时,页面在哪里显示(例如:PC 页面用支付宝付款时,会跳转到支付宝页面)
事件
onsubmit 当点击 submit 时会触发 onsubmit
input 标签
作用:
让用户输入内容
属性
类型 type
button: 按钮(用于提交)
color:颜色选择器
checkbox:多选框
file:上传文件/multiple 属性可多文件上床
password:密码框
submit:每个 form 必须有,
text:文本
textarea:多行文本输入
radio:单选按钮
select+option:多项选择
其他属性
name 名字
value 值
事件
onchange:当改变时,触发
onfocus:当聚焦时,触发
onblur:当离开时,触发
验证器
属性 required 必需填写
form 里面的 input 要有 name
form 里面放一个 type=“submit”才能触发 submit 事件