HTML常用标签

210 阅读1分钟

a 标签

a标签的属性:

  1. a标签的href取值=hyper reference
  2. a标签的target取值
  3. download
  4. rel=noopener

a标签的href取值

  • 网址:
    1. google.com
    2. google.com
    3. //google.com (无协议网址)
  • 路径:
    1. /a/b/c以及a/b/c
    2. index.html以及./index.html
  • 伪协议:
    1. javascript:代码;
    2. mailto:邮箱
    3. tel:手机号
    4. id href=#xxx

a标签的target取值

  • 内置名字:
    1. _blank 在空白页面打开
    2. _top 在顶级页面打开
    3. _parent 在当前链接iframe上一层打开
    4. _self 默认值
  • 程序员命名
    1. window的名字
    2. iframe的名字

download

  1. 作用:不是打开页面,而是下载页面
  2. 问题:不是所有浏览器都支持,尤其是手机浏览器可能不支持

a标签的作用

  1. 跳转外部页面
  2. 跳转内部锚点
  3. 跳转到邮箱或电话等

img 标签

  • 作用:发出get请求,展示一张图片
  • 属性:
    1. src=source 图片地址
    2. alt=alternative 图片显示错误,给个提示
    3. height/width 永远不要让图片变形
  • 事件:onload/onerror 监听图片是否加载成功
  • 响应式:max-width:100% 手机端适配
  • 可替换元素 (面试问题)

table 标签

  • <table>
    
  • <thead>
    
  • <tbody>
    
  • <tfoot>
    
  • <tr>table row</tr>
    
  • <th>table head</th>
    
  • <td>table data</td>
    

table 标签相关的样式

  • table-layout
  • border-collapse: collapse;
  • border-spacing: 0;