Html、Html5常用标签

160 阅读2分钟

一. a标签

  • href —— hyper reference的缩写。超链接。指定跳转的页面路径或者伪协议、锚点。

    • 网址
      • http
      • https
      • 省略http,https,会继承当前页面的网络协议打开新的窗口
    • 相对路径和绝对路径
      • http的根目录是http的启用目录
    • 伪协议
      • javascript 无任何作用的a标签

           <a href="javascript;">无任何作用的链接</a>
        
      • mailto 打开默认邮箱应用发邮件(收件人的电子邮件地址)

            <a href = "mailto:C1787153006@outlook.com">邮件</a>
            
        
      • tel 打开默认拨号应用打电话(点击直接拨打电话)

             <a href="tel:18755675735">18755675735</a>
        
  • target —— 如何跳转即在哪里打开页面

    • _self: 在当前窗口打开 (默认)
    • _blank: 打开一个新窗口的方式打开
    • _parent: 在上一级页面打开 ,通常在 iframe
    • _top: 在根页面打开, 通常在 iframe
  1. 跳转网页

             <a href="http://www.baidu.com"  target="_self"></a>      // 当前窗口打开
             <a href = "http://www.baidu.com" target ="_blank"></a>   // 新窗口打开
     
    
  2. 锚点连接 —— 快速定位到当前页面的某一个位置

  • 设置跳转链接 href —— 标签的id 值 ,前面需要加 #

          <h3 id="Jump">锚点连接的使用</h3>
          <a href="#Jump">跳转</a>
    
  1. 跳转到邮箱 mailto 或电话应用 tel

          // 跳转到邮箱, 收件人地址
          <a href = "mailto:C1787153006@outlook.com">邮件</a>  
          // 跳转到电话应用,默认拨号
          <a href="tel:18755675735">18755675735</a>
          
    
  2. download 下载

    href 链接到 html文件是打开新的页面,其他的都是下载

二. table标签

  • thead : 表头
  • tbody :表格主体
    • tr :表示行 table row的简写
    • th : 表示单元格的表头 table head的简写
    • td :表示普通单元格 table data
  • tfoot :尾部

相关样式

  • table-layout

    • 设置列宽 ,默认auto,根据内容自适应列宽
    • fixed : 列宽一致
  • border-spacing (css属性) / cell-spacing (table标签属性)

    • 单元格间隙 chrome 默认 2px 的间隙
  • border-collapse

    • separate 边框分开,不合并(默认)
    • collapse 边框合并,如果相邻,则共用一个边框

三. Video/Audio标签(Html5新增视频标签,标签属性)

  • src : source的缩写,输入视频的路径或地址;

  • autoplay : 自动播放 ,chrome不会自动播放,除非设置静音模式;

  • controls : 设置播放控制器,控制器格式跟随浏览器

  • muted : 设置静音

  • loop : 设置循环播放

  • poster : 网速很卡时,视频为加载出来时,显示的图片(video特有)

<video src="video/武汉日夜.mp4" autoplay="autoplay" controls="contrlos" muted="muted" loop="loop" poster="images/video常见属性.png"> </video>
<audio src="audio/素颜.mp3" autoplay = "autoplay" controls="controls",loop="loop"></audio>

四. input(表单控件,标签属性)

属于表单控件,需要验证时,要用form表单域包裹

  • type 表单控件的类型

     <input type = "email">邮箱 email</input>
     <input type = "date"> 日期 date </input>
     <input type = "month"> 月  month </input>
     <input type = "week"> 周 week </input>
     <input type = "time"> 时间 time  </input>
     <input type = "url"> 网址 url </input>
     <input type = "number"> 数量 number </input>
     <input type = "tel">电话 tel </input>
     <input type = "search"> 搜索 search</input>
     <input type = "color"> 颜色表单 color </input>
     ********** 以上为Html5 新增的特性 *************
     
     <input type = "text"> 文本 text </input>
     <input type = "area"> 文本输入框 area </input>
     <input type = "file"> 上传文件 file </input>
     <input type = "submit"> submit 默认提交表单 </input>
    
  • required 内容不能为空

  • placeholder 提示文本

  • autofocus 自动获取焦点

  • autocomplete 是否提示以前输入的文本 on/off

      <input type = "text" required="required" placeholder="请输入..." autofocus="autofocus" autocomplete="on"> </input>
    
  • mutiple file类型里上传文件可多选

      <input type = "file" mutiple="mutiple"> </input>