href和src的使用情境

來源:互聯網
上載者:User

標籤:底部   html   文檔   sub   wav   嵌入   區別   click   control   

  href和src的用法雖然簡單,但是有時候會突然記不起來該怎麼用,且兩者不可相互替換,下面列出來方便記憶,並給出具體區別。

 

 

     href的使用: 

         1.外部css引用:<link type="text/css" rel="stylesheet" href="../css/test.css" />

     2.<a>標籤的使用: <a href="http://www.baidu.com" target="_blank">百度</a>

         3.input中type為button等的onclick事件:<input type=button onclick="window.location.href(‘#‘)" />

 

 

     src的使用:

  1. 引入圖片img: <img src="/img/1.png" alt="1" />
  2. scirpt 指令碼 :<script type="text/javascript" src="org.js"></script>
  3. iframe架構: <iframe src="girl.gif"></iframe>  
  4. input中type為image的提交按鈕: <input type="image" src="1.png" alt="Submit" />
  5. html5中的vidio元素:<video src="movie.ogg" controls="controls">video元素</video>
  6. html5中的audio元素:<audio src="someaudio.wav">audio元素</audio>
  7. html5中的embed元素:<embed src="horse.wav"/>

 

 

  href和src的區別:

       src (Source)屬性僅僅 嵌入當前資源到當前文件項目定義的位置。當瀏覽器找到<script src="script.js"></script>,在瀏覽器下載,編譯,執行這個檔案之前頁面的載入和處理會被暫停。這個過程與把js檔案放到<script>標籤裡類似。這也是建議把JS檔案放到底部載入的原因。當然,img標籤頁與此類似。瀏覽器暫停載入直到提取和載入映像。

 

 

   

href和src的使用情境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.