Usage scenarios for href and SRC

Source: Internet
Author: User

The use of href and src is simple, but sometimes it suddenly can't remember how to use, and the two can not replace each other , listed below to facilitate the memory, and give specific differences.

 

Use of href:

1. External CSS reference: <link type= "Text/css" rel= "stylesheet" href= ". /css/test.css "/>

Use of 2.<a> Tags:<a href="http://www.baidu.com" target="_blank">百度</a>

3.the onclick event in input type is button, etc.: <input type=button onclick= "Window.location.href (' # ')"/>

 

Use of SRC:

    1. Introduce image img:
    2. Scirpt script:<script type="text/javascript" src="org.js"></script>
    3. iframe frame : <iframe src= "Girl.gif" ></iframe>
    4. The type in input is the submit button for Image: <input type= "image" Src= "1.png" alt= "Submit"/>
    5. Vidio elements in HTML5:<video src= "Movie.ogg" controls= "controls" >video elements </video>
    6. Audio elements in HTML5:<audio src= "someaudio.wav" >audio elements </audio>
    7. Embed elements in HTML5:<embed src= "Horse.wav"/>

The difference between href and src:

the SRC (Source) property embeds only the current resource to the location defined by the current document element. When the browser finds <script src= "Script.js" ></script>, the loading and processing of the page will be paused before the browser downloads, compiles, and executes the file. This process is similar to putting the JS file in the <script> tab. This is also recommended to put the JS file to load the bottom of the reason. Of course, the IMG tab is similar to this. The browser pauses loading until the image is extracted and loaded.

 

   

Usage scenarios for href and SRC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.