The difference between src and href in html

Source: Internet
Author: User

Write code often confuse these two properties, in the end is the href or src,href identifies a hypertext reference, used in link and a and other elements,href is a reference and page association, is to establish a connection between the current element and the reference resource,src means referencing the resource, representing the replacement of the current element, and on the img,script,iframe , SRC is an integral part of the page content.

  SRC is the abbreviation for source, which is the location of the external resource, which is moved to the location of the current label in the document, and the resource it points to is downloaded and applied to the current document when the src resource is requested, such as the JS script, IMG images and frame elements.

<script src= "Js.js" ></script> when the browser resolves to this sentence, it pauses the download and processing of other resources until the resource is loaded, compiled, executed, and so is the image and frame elements. Similar to the resource that the element points to is nested within the current tag, which is why the JS rice is then the bottom instead of the head.

<link href= "Common.css" rel= "stylesheet"/> when the browser resolves to this sentence will recognize the document as a CSS file, will download and will not stop the processing of the current document, This is also why it is recommended to use the link method to load CSS instead of using @import.

Add: The difference between link and @import

Both are external ways of referencing CSS, but there are some differences:

The difference between 1:link is XHTML tags, in addition to loading CSS, you can also define RSS and other transactions, @import belong to the CSS category, can only load CSS.

The difference between 2:link referencing a CSS, loading at the same time when the page loads, @import need to load the page after full loading.

The difference between 3:link is XHTML label, no compatibility problem, @import is proposed in CSS2.1, the lower version of the browser is not supported.

The difference 4:ink supports using JavaScript to control the DOM to change styles, while @import does not support it.

  

The difference between src and href in html

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.