Home Web Front-end CSS Tutorial What is the difference between href and src, link and @import?

What is the difference between href and src, link and @import?

Mar 21, 2018 pm 03:20 PM
@import href link

This time I will bring you the difference between href and src, link and @import, what are the precautions when using href and src, link and @import, the following is a practical case, let's take a look one time.

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. img

TabSimilarly, the browser pauses 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, you 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 Use JavaScript to control the DOM to change the style; while @import does not support it.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to use attribute value inheritance in css

Double Flying Wing Layout and Holy Grail Layout Detailed Graphical Explanation


The above is the detailed content of What is the difference between href and src, link and @import?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

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 ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What do src and href mean? What do src and href mean? Aug 16, 2023 pm 05:00 PM

src and href are respectively, 1. src is the abbreviation of source, which is used to specify the path of external resources. It is usually used to embed external files, such as pictures, audios, videos, etc. The src attribute is generally used on img, script, iframe and other tags. ; 2. href is the abbreviation of hypertext reference, which is used to specify the path of the target resource of the hyperlink. It is usually used to link to external documents or other pages. The href attribute is generally used on tags such as a and link.

How to use the @Import annotation in SpringBoot How to use the @Import annotation in SpringBoot May 31, 2023 pm 06:25 PM

1. @Import introduces ordinary classes @Import introduces ordinary classes can help us define ordinary classes as Beans. @Import can be added to the classes corresponding to @SpringBootApplication (startup class), @Configuration (configuration class), and @Component (component class). Note: @RestController, @Service, and @Repository all belong to @Component@SpringBootApplication@Import(ImportBean.class)//ImportBean through the @Import annotation

What are the differences in functions and usage between the src attribute and the href attribute? What are the differences in functions and usage between the src attribute and the href attribute? Dec 28, 2023 am 08:20 AM

The src attribute and href attribute are commonly used attributes in HTML and are used to load external resources. Although they have similar purposes, there are some differences in usage and purpose. src attribute: The src attribute is used to specify external resources to be embedded in the document. It is mainly used to introduce external script files and media files into HTML documents. It can be used in the following situations: Introduce external JavaScript files: Link external JavaScript files to HTML pages through the src attribute.

The difference between link and import is explained in detail: What are the differences between them? The difference between link and import is explained in detail: What are the differences between them? Jan 06, 2024 am 08:19 AM

In-depth analysis: What is the difference between link and import? When developing web pages or applications, we often need to introduce external CSS files or JavaScript libraries to enhance or customize our code. In this process, link and import are two commonly used methods. Although their purpose is to introduce external resources, there are some differences in specific usage. Syntax and location: link: Use the link tag to link external resources into the HTML file, usually located at the head of the HTML document

Learn the important details about the difference between src and href! Learn the important details about the difference between src and href! Jan 06, 2024 am 09:11 AM

The difference between src and href, details you must know! When writing HTML pages, we often encounter the two attributes src and href. They are both used to reference external resources, such as script files, style files, or images. Although their purposes are similar, there are some differences in their specific usage and details. First of all, the src (source) attribute is mainly used to embed external resources, such as pictures or scripts. It is used to specify the address of a resource and embed its content into the current document. And href(

What is the difference between link tag and import? What is the difference between link tag and import? Aug 28, 2023 am 11:19 AM

The differences between link tags and import include syntax and usage, functions and features, loading timing, compatibility and support, etc. Detailed introduction: 1. Syntax and usage. The link tag is an HTML tag, used to introduce external resources into HTML documents, such as CSS style sheets, JavaScript scripts, icons, etc. import is the module import syntax in ES6, used in JavaScript files. Introduce external modules; 2. Functions and features. The link tag can introduce a variety of resources, such as CSS style sheets, icons, etc.

What request is sent by href and src? What request is sent by href and src? Aug 17, 2023 pm 02:20 PM

Get requests sent by href and src. Detailed description: 1. The href attribute is used to specify the target resource of the link. When referencing an external style sheet, it will send a GET request to obtain the CSS file. When referencing the document, it will send a GET request to obtain the specified HTML file. When referencing an image, it will send a GET request. To obtain the specified image file; 2. The src attribute is used to specify the URL of the embedded resource. When referencing the image, it will send a GET request to obtain the specified image file. When referencing the audio, it will send a GET request to obtain the specified audio file, etc. .

What are the differences between import and link What are the differences between import and link Nov 24, 2023 pm 02:15 PM

The difference between import and link: 1. Purpose and semantics; 2. Loading method; 3. Compatibility; 4. Linking multiple style sheets; 5. Media type; 6. Dynamics; 7. Error handling; 8. Embedding set; 9. Default style; 10. Compatibility considerations; 11. Performance considerations; 12. Usage scenarios. Detailed introduction: 1. Purpose and semantics. Link is an HTML tag, used to link to external CSS files or style sheets. It is usually located in the head part of the HTML document, import is part of CSS, etc.

See all articles