HTML常用标签

158 阅读1分钟

永远不要双击打开html文件,而是使用http-server来打开(像用户一样使用网页)。

输入命令行 http-server . -c-1,缩写hs . -c-1

<a>标签

href取值

  • 网址:http://google.com, https://google.com, //google.com
  • 路径:/a/b/c以及a/b/cindex.html以及./index.html
  • 伪协议:空的JS伪协议,点击该链接什么操作都不做,不跳转,不刷新<a href="javascript:;">查看</a>mailto:tel:
  • id:<a href=#XXX>

target取值

  • 内置名字:_blank空白页面打开, _top顶级窗口打开, _parent当前链接所在页面的上一级窗口打开, _self默认值,当前页面打开。
  • 程序员的命名:window的name,iframe的name。

download

不是打开页面,而是点击链接直接下载页面,但不是所有浏览器都支持,尤其是手机浏览器可能不支持。

rel=noopener

作用

  • 跳转外部页面
  • 跳转内部锚点
  • 跳转到邮箱或者电话等

<img>标签

作用

发出get请求,展示一张图片

属性

  • alt:设定图片的文字说明。图片不显示时,图片的位置上会显示该文本
  • heightwidth:图片默认以原始大小插入网页。这两个属性可以指定图片显示时的高度和宽度,单位是像素或百分比。
  • src

事件

onload/onerror

响应式

max-width: 100%

可替换元素

<table>标签

<body>
    <table>
        <thead>
            <tr>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td></td>
            </tr>
        </tfoot>
    </table>
</body>

\