HTML常用标签

298 阅读1分钟
a 标签

属性

  • href

    • 网址 //google.com

    • 路径

    • 伪协议 javascript:代码; <a href="javascript:alert(1);"> <a href="javascript:;">

      ​ mailto:邮箱

      ​ tel:手机

  • target

    • 内置名字
      • _blank 新的空白窗口打开
      • _top 顶层窗口打开
      • _parent 父级窗口打开
      • _self 默认的,在当前窗口打开
  • download

  • rel=noopener

作用:跳转外部页面、跳转内部锚点、跳转到邮箱或电话等

table

相关标签:table thead tbody tfoot tr td th

相关的样式

  • table-layout
  • boder-collapse
  • boder-spacing
img 标签

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

属性:alt (图片加载失败时的提示文字) height width src

事件:onload onerror 监听图片加载成功或失败

响应式:max-width:100%

form 标签

作用:发 getpost请求,然后刷新页面

属性

  • action 请求地址
  • autocomplete 是否自动填充
  • method 请求方法(get/post)
  • target

事件:onsubmit

button标签里可以有任何东西,input里不可以

input 标签

作用:让用户输入内容

属性:

  • 类型 type :button / checkbox / email / file / hidden / number / password / radio / search / submit / tel / text
  • 其他属性:name / autofocus / checked / disabled / malength / pattern / value / placeholder

事件: onchange / onfocus / onblur

验证器

注意事项:

  • 一般不监听 input 的 click 事件
  • form 里面的 input 要有 name
  • form 里面要放一个 type=submit 才能触发 submit 事件