<a>标签
作用:跳转至外部页面、内部锚点、邮箱或电话等
属性
href
=hypertext reference,超文本链接
- 网址
<a href="https://google.com"></a>
<a href="http://google.com"></a>
<a href="//google.com"></a>
无协议网址,会自动补全
- 路径
- 绝对路径:
href="/a/b/c"
- 相对路径:
href="a/b/c"
,href="./a/b/c"
- 绝对路径:
- 伪协议
- JavaScript伪协议:javascript:代码;
- eg:
herf="javascript:alert(1);"
执行alert(1) - eg:
herf="javascript:;"
点击后无反应(href=""
时页面刷新,href="#"
页面不会刷新,但会跳转至最顶端)
- eg:
href="mailto:邮箱地址"
href="tel:电话号码"
- JavaScript伪协议:javascript:代码;
- 锚点
herf="#id"
,可以跳转至指定位置
target
指定在何种窗口打开超链接
-
内置名称
-
target="_blank"
:在新的空白标签页打开超链接注意:在
<a>
元素上使用target="_blank"
隐式提供了与使用rel="noopener"
相同的rel
行为,即不会设置window.opener
。[1] -
target="_top"
:在最顶层窗口打开超链接 -
target="_parent"
:在父级窗口打开超链接 -
target="_self"
:在自身窗口打开超链接(默认)
-
-
需要自行命名
-
1 2
<a href="//google.com" target="newWindow"></a> <a href="//baidu.com" target="newWindow"></a>
如果当前有名为newWindow的窗口,则在该窗口打开链接,若没有该窗口,则创建一个名称为newWindow的窗口打开链接。
-
1 2 3 4
<a href="//google.com" target="google"></a> <a href="//baidu.com" target="baidu"></a> <iframe src="" name="google"></iframe> <iframe src="" name="baidu"></iframe>
在不同name的iframe框架内打开链接
-
download
下载网页(并非所有浏览器都支持,尤其是手机浏览器可能不支持)
<img>标签
作用:发出get请求,展示一张图片
属性
alt
- alternative,当图片加载失败时所显示的内容
height
- 只写高度,宽度会自适应 避免同时设置宽高,永远不要使图片变形
width
- 只写宽度,高度会自适应 避免同时设置宽高,永远不要使图片变形
src
- source,即图片地址
事件
onload
图片加载成功时执行
|
|
onerror
图片加载失败时执行
|
|
一般图片加载失败后,可以进行补救
|
|
响应式
|
|
<table>标签
表格
完整格式
|
|
注意
- 如果表格编写中没有书写
<thead>
、<tbody>
和<tfoot>
,浏览器会自动补充<tbody>
,并将<tr>
内全部内容填补其中。 <thead>
、<tbody>
和<tfoot>
顺序可以颠倒,浏览器会自动纠正。
相关样式
-
table-layout:
1 2 3 4 5 6
<style> table{ table-layout: auto; <!-- 根据内容长度,自动计算宽度 --> table-layout: fixed; <!-- 表格宽度尽量等宽 --> } </style>
-
border-collapse
1 2 3 4 5
<style> table{ border-collapse: collapse; <!-- 合并单元格 --> } </style>
-
border-spacing
1 2 3 4 5 6
<style> table{ border-spacing: 0; <!-- 单元格空隙为0 --> border-spacing: 10px; <!-- 单元格上下左右空隙10px --> } </style>
<form>标签
作用:发送get或者post请求,然后刷新页面
施工中…………正在努力补全(((o(゚▽゚)o)))