search
HomeWeb Front-endCSS TutorialDetailed explanation of the differences between href and src, link and @import in css

This article mainly introduces the differences between href and src, link and @import, and explains the noun definitions and application scenarios. Friends in need can refer to it. I hope it can help everyone.

The difference between href and src:

##href (Hypertext Reference): Hypertext reference, commonly used tags are link, a, etc., are used to link referenced external resources. Define a link or relationship between the current element or current document and the required anchor or resource defined by the current attribute, such as:


src(source): Introduce resources. The content of the imported src is an essential part of the page. The imported content will embed the current resource into the position defined by the current document element. Commonly used ones include: img, script, iframe, etc. For example:


Loading and processing of the page before the browser downloads, compiles, and executes this file will be paused (when the browser parses the element, the browser's rendering will be paused), which is why it is recommended to load the js file at the bottom. The img tag is similar, with the browser pausing loading until the image is fetched and loaded.

The difference between link and @import:

Both are ways of externally referencing CSS, but the differences are as follows :

Difference 1: link is an XHTML tag. In addition to loading CSS, it can also define other transactions such as RSS; @import belongs to the CSS category and can only load CSS.

Difference 2: When the link references CSS, it is loaded at the same time when the page is loaded; @import requires the page to be fully loaded before loading.

Difference 3: link is an XHTML tag and has no compatibility issues; @import was proposed in CSS2.1 and is not supported by lower version browsers.

Difference 4: link supports using JavaScript to control the DOM to change the style; @import does not support it.

Related recommendations:

Detailed explanation of the difference between nth-child and nth-of-type in CSS3

Detailed explanation of the difference between addEventListener and on

What is the difference between br, p and DIV in html

The above is the detailed content of Detailed explanation of the differences between href and src, link and @import in css. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
src和href是什么意思src和href是什么意思Aug 16, 2023 pm 05:00 PM

src和href分别是,1、src是source的缩写,用于指定外部资源的路径,通常用于嵌入外部文件,比如图片、音频、视频等,src属性一般用在img、script、iframe等标签上;2、href是hypertext reference的缩写,用于指定超链接的目标资源的路径,通常用于链接到外部文档或其他页面,href属性一般用在a、link等标签上。

SpringBoot中的@Import注解怎么使用SpringBoot中的@Import注解怎么使用May 31, 2023 pm 06:25 PM

一、@Import引入普通类@Import引入普通的类可以帮助我们把普通的类定义为Bean。@Import可以添加在@SpringBootApplication(启动类)、@Configuration(配置类)、@Component(组件类)对应的类上。注意:@RestController、@Service、@Repository都属于@Component@SpringBootApplication@Import(ImportBean.class)//通过@Import注解把ImportBean

src属性和href属性在功能和用法上的区别有哪些?src属性和href属性在功能和用法上的区别有哪些?Dec 28, 2023 am 08:20 AM

src属性和href属性是在HTML中常用的属性,用于加载外部资源。虽然它们有相似的目的,但在使用和用途上有一些不同。src属性:src属性用于指定要在文档中嵌入的外部资源,主要用于在HTML文档中引入外部脚本文件和媒体文件。它可以用于以下几种情况:引入外部JavaScript文件:通过src属性,将外部的JavaScript文件链接到HTML页面。

link和import的区别细说:分析它们有何不同?link和import的区别细说:分析它们有何不同?Jan 06, 2024 am 08:19 AM

深入解析:link与import的区别是什么?在开发网页或应用程序时,我们经常需要引入外部的CSS文件或JavaScript库来增强或定制我们的代码。在这个过程中,link和import是两种常用的方法。虽然它们的目的都是引入外部资源,但在具体的使用上存在一些区别。语法和位置:link:使用link标签将外部资源链接到HTML文件中,通常位于HTML文档的头

了解src和href的不同点的重要细节!了解src和href的不同点的重要细节!Jan 06, 2024 am 09:11 AM

src和href的差异,你不可不知的细节!在编写HTML页面时,我们经常会遇到src和href这两个属性。它们都用于引用外部资源,比如脚本文件、样式文件或者图片。虽然它们的用途相似,但它们在具体的用法和细节上却存在一些差异。首先,src(source)属性主要用于嵌入外部资源,比如图片或者脚本。它是用于指定资源的地址,并将其内容嵌入到当前文档中。而href(

link标签和import有什么区别link标签和import有什么区别Aug 28, 2023 am 11:19 AM

link标签和import的区别有语法和用途、功能和特性、加载时机、兼容性和支持等。详细介绍:1、语法和用途,link标签是HTML标签,用于在HTML文档中引入外部资源,如CSS样式表、JavaScript脚本、图标等,import是ES6中的模块导入语法,用于在JavaScript文件中引入外部模块;2、功能和特性,link标签可以引入多种资源,如CSS样式表、图标等等。

href和src发送的什么请求href和src发送的什么请求Aug 17, 2023 pm 02:20 PM

href和src发送的get请求。详细说明:1、href属性,用于指定链接的目标资源,引用外部样式表会发送GET请求来获取CSS文件,引用文档会发送GET请求来获取指定的HTML文件,引用图像时它会发送GET请求来获取指定的图像文件;2、src属性,用于指定嵌入资源的URL,引用图像时会发送GET请求来获取指定的图像文件,引用音频它会发送一个GET请求来获取指定的音频文件等等。

import和link之间有哪些区别import和link之间有哪些区别Nov 24, 2023 pm 02:15 PM

import和link之间的区别:1、用途和语义;2、加载方式;3、兼容性;4、链接多个样式表;5、媒体类型;6、动态性;7、错误处理;8、嵌套;9、默认样式;10、兼容性考虑;11、性能考虑;12、使用场景。详细介绍:1、用途和语义,link是HTML标签,用于链接到外部的CSS文件或样式表,它通常位于HTML文档的head部分,import是CSS的一部分等等。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment