Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src和href的区别 #18

Open
conan1992 opened this issue Jun 16, 2020 · 0 comments
Open

src和href的区别 #18

conan1992 opened this issue Jun 16, 2020 · 0 comments

Comments

@conan1992
Copy link
Owner

href

href是 Hypertext Reference的简写,表示超文本引用,指向网络资源位置;

<a href="http://www.baidu.com"></a> 
<link type="text/css" rel="stylesheet" href="common.css"> 

src

是source的简写,目的是把文件下载到html中;

<img src="img/girl.jpg"></img> 
<iframe src="top.html"> 
<script src="show.js"> 

作用结果

  1. href用于建立页面和资源的联系
  2. src替换当前内容

注:

  • 当浏览器遇到href会并行下载资源,而不会停止对当前文档的处理(这就是css用link不用@import的原因)
  • 当浏览器遇到src会停止对其他资源的下载和处理,直到该资源下载完毕(这就是script标签放在文档最后比较好的原因)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant