HTML常用标签

149 阅读1分钟

a标签

通常用来定义一个超链接 代码示例:

1. <a href="//baidu.com" target="_blank">百度</a>
2. <a href="mailto:1770554944@qq.com" target="_blank">我的邮箱</a>

属性:

• href:超链接地址

• targrt:页面在哪里打开

内置名字:

ⅰ. _self在本窗口打开 ⅱ. _blank在新窗口打开 ⅲ. _parent再上一层打开 ⅳ. _top在顶级页面打开

• download • rel

table标签

表示表格数据——即通过二维数据表表示的信息 代码示例:

<table >
        <thead>
            <tr>
                <th></th>
                <th>输入数量</th>
                <th>输出</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th>第一天</th>
                <td>54</td>
                <td>65</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>第二天</th>
                <td>55</td>
                <td>11</td>
            </tr>
        </tfoot>
 </table>
  • 相关标签: thead,tbody,tr,tfoot,th,td
  • 相关样式:
  1. table-layout:根据内容,自动匹配;
  2. border-spacing:border之间的距离;
  3. border-collapse:border之间是否合并。

img标签

将一份图像嵌入文档。 代码示例:

<img src="/1.png" alt="出错啦">
  • 属性:alt,src,width,height
  • 事件:onload.onerror
  • 响应式:max-width:100% --> 使图片大小可以适应窗口大小,使图片可以在手机上全部显示。

form标签

表单,示文档中的一个区域,此区域包含交互控件,用于向 Web 服务器提交信息。 代码示例:

<form action="//baidu.com">
        <input type="text">
        <input type="submit">
</form>
  • 作用:发get或post请求,刷新页面。
  • 属性:action:请求那个页面; method:选择get/post autocomplete:自动给出建议,如在input上有name="username"时。 target
  • 事件:onsubmit

input标签

用于为基于Web的表单创建交互式控件,以便接受来自用户的数据; 可以使用各种类型的输入数据和控件小部件,具体取决于设备和user agent。

  • 类型:text,button,checkbox,email,number,passward,radio,submit等
  • 事件:onchange,onfouse,onblur