Skip to content

8.简述一下 src 与 href 的区别 #8

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

Open
webVueBlog opened this issue Mar 10, 2020 · 1 comment
Open

8.简述一下 src 与 href 的区别 #8

webVueBlog opened this issue Mar 10, 2020 · 1 comment
Labels
HTML&CSS HTML&CSS

Comments

@webVueBlog
Copy link
Member

href 是指向网络资源所在位置,建立和当前元素(锚点)或当前文档(链接)
之间的链接,用于超链接。

src 是指向外部资源的位置,指向的内容将会嵌入到文档中当前标签所在位
置;在请求 src 资源时会将其指向的资源下载并应用到文档内,例如 js 脚本,img
图片和 frame 等元素。

当浏览器解析到该元素时,会暂停其他资源的下载和处理,直到将该资源加
载、编译、执行完毕,图片和框架等元素也如此,类似于将所指向资源嵌入当前
标签内。这也是为什么将 js 脚本放在底部而不是头部。

@webVueBlog webVueBlog added the HTML&CSS HTML&CSS label Mar 10, 2020
@webVueBlog
Copy link
Member Author

The href points to the location of the network resource and creates the current element (anchor) or document (link)
Between links for hyperlinks.

SRC is the location that points to an external resource, which will be embedded in the bit of the document where the current label is located
Buy; When a SRC resource is requested, the resource it points to is downloaded and applied to the document, such as a js script or img
Elements like images and frames.

When the browser parses the element, it suspends the downloading and processing of other resources until the resource is added
Load, compile, and execute, as do elements such as images and frames, similar to embedding the pointed resource into the current
Tags. This is why the js script is placed at the bottom instead of the head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTML&CSS HTML&CSS
Projects
None yet
Development

No branches or pull requests

1 participant