HTML常用标签

91 阅读1分钟

<a>标签

href的取值

  • 网址

  1. google.com
  2. google.com
  3. //google.com(推荐使用)
  • 路径

  1. /a/b/ca/b/c
  2. index.html.index.html
  • 伪协议

  1. javascript:代码;(javacript:;点击后不做任何反应)
  2. mailto:邮箱
  3. tel:手机号
  • id

  1. href=#xxx点击后跳转到id为xxx的元素

target的取值

  • _blank在空白页面打开
  • _self在当前页面打开
  • _parent在上一级页面打开
  • _top在顶层打开

<img>标签

  • 作用

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

  • 属性

  1. alt对图片的文字描述
  2. height图片的高度
  3. width图片的宽度(用max-width=100%来实现响应式页面)
  4. src文件的地址
  • 事件

onload/onerror判断图片是否加载成功


<table>标签

  • 相关的标签

  1. <thead>表格头部
  2. <tbody>表格主要内容
  3. <tfoot>表格尾部
  4. <tr>
  5. <td>表格的数据
  6. <th>表头
  • 相关的样式

  1. table-layout显示表格单元格、行、列的算法规则
  2. boder-collapse使表格边框合并
  3. border-spacing边框的间距

其他

  • max-with=100%可以在手机上实现响应式页面
  • onload/onerror可以实现在图片不能加载时显示预设好的图片
  • 不要让图片变形
  • 不要双击打开html文件
  • 不输入<tbody>标签浏览器也会自动补齐
  • <thead><tbody><tfoot>的顺序可以随意更改