Home > Article > Web Front-end > The difference between css and @import usage
css and @import are both methods of calling external style sheets.
1. Usage
(1)link:
(2)@import:
Method 1 (added in html):
@import url(css file path);
Method 2 (added in css):
@import url(css file path);
2. Difference
(1) link is an XHTML tag. In addition to loading CSS, it can also define other transactions such as RRS. @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.