HTML常用标签

133 阅读1分钟

a标签的用法

作用

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

属性

  • href
  1. 网址
  2. href="https://google.com"

    href="http://google.com"

    href="//google.com";无协议网址,自动选择适用http或https

  3. 路径
  4. herf="/a/b/c"或herf="a/b/c"

    herf="index.html"或herf="./index.html"

  5. 伪协议
  6. javascript:代码; herf="javascript: alert(1);" herf="javascript:;"(让a标签什么都不做)

    mailto: 邮箱

    tel: 手机号

  7. ID
  8. herf="#id";跳转道指定标签

  • target
    1. 内置名字
    2. _blank 在空白页面打开

      _top 在顶层打开

      _parent 在当前链接所在的上一层打开

      _self 默认值,在当前页面打开

    3. 程序员命名
    4. window的name

      iframe的name

      1.PNG

  • download
    1. download="//google.com"

      下载网页,但不是所用所有网站都支持

  • rel=noopener
  • img标签的用法

    作用

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

    属性

    • alt
    • 图片加载失败时,显示一段提示文字

    • height
    • 设置高度

    • width
    • 设置宽度

    • src
    • 设置图片地址

    事件

    • onload/onerror
    • 用于监听图片是否加载成功;成功时调用onload,失败时调用onerror

      image.png

    table标签的用法

    作用

    定义html表格

    属性

    • thead
    • 定义表格的页眉

    • tbody
    • 定义表格的主体

    • tfoot
    • 定义表格的页脚

    • tr
    • 定义表格的行

    • td
    • 定义表格单元

    • th
    • 定义表格的表头

    相关样式

    • table-layout
    • boeder-collapse
    • border-spacing