HTML常用标签

98 阅读1分钟

HTML常用标签

一、a 标签的用法

1. 属性

href:超链接

eg.

<a href="//google.com">名字</a>

target:在哪个窗口打开超链接

eg.

<a href="a/b/c.html" target="_blank">超链接</a>

可以内置名字

  • _blank 空白窗口打开
  • _self 自己窗口打开(缺省)
  • _top 顶层打开
  • _parent 父级窗口打开 可以程序员命名:window、iframe的name

download:下载网页(很少用)

rel=noopener

2. 作用

跳转到外部页面/内部锚点/邮箱/电话

二、img 标签的用法

1. 属性

  • alt 加载失败后,写字提示用户
  • width 宽
  • height 高 其中只写宽/ 高,另一个会自适应
  • src 地址

2. 作用

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

3. 事件

onload 成功,onerrer 失败

4. 响应式

5. 可替换元素

三、table 标签的用法

1. 格式

  • thead 头部
  • tbody 主体
  • tfoot 尾部
  • tr table row 一行
  • th table head 表头
  • td table data 表内数据 eg.
<table>
        <thead>
            <tr>
                <th>英语</th>
                <th>翻译</th>
            </tr>
            <tr>
                <th>英语</th>
                <th>翻译</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>target</td>
                <td>目标</td>
            </tr>
            <tr>
                <td>reference</td>
                <td>引用</td>
            </tr>
        </tbody>
    </table>

2. 相关样式

eg.

<style>
    table{
        table-layout: auto;
        border-collapse: collapse;
        border-spacing: 0ch;
      
    }
    th,td{
        border: 1px solid blue;
    }
</style>

感想

html挺简单,加油!