A brief discussion on the difference between css and @import and detailed explanation of their usage

高洛峰
Release: 2017-03-03 16:44:15
Original
1819 people have browsed it

The editor below will bring you a brief discussion on the differences and usage between css and @import. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

css and @import are both methods of calling external style sheets.

1. Usage

(1)link:

(2)@import:

Method 1 (added in html):

Method 2 (added to css):

@import url (css file path);

2. Difference

(1) link is an XHTML tag, in addition to loading CSS In addition, other transactions such as RRS can also be defined. @import belongs to the CSS category and can only load CSS.

(2) The link references the CSS style, which is loaded synchronously with the page loading. @import waits until the page is loaded before starting to load.

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

(4) link supports using Javascript to control the DOM to change the style; while @import does not support it.

The above article briefly discussing the differences and usage between css and @import is all the content shared by the editor. I hope it can give you a reference, and I hope you will support the PHP Chinese website.


Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template