Summarize the differences between link and @import in loading css

零下一度
Release: 2017-05-09 14:14:57
Original
1391 people have browsed it

Two ways to load css: <link> @import

  • ##Way

       <link rel="stylesheet" href="a.css" />
        @import url("b.css");
    Copy after login

  • Comparative explanation

    • How to set styles: inline style, inline style, outline style, import Style

    • When @import is used with inline style

      , inline style>import style

    • Except for the above situation, at other times, the style loading order is used as a reference, and the later loaded

      priority is higher. (Already tested, you can also refer here) Remember when testing, you must use the same selector for the same element to test, otherwise there will be interference from the selector weight.

    • link belongs to the X

      HTML tag , and @import is provided by CSS; in addition to loading CSS, the link tag can also do many other things. @import can only load CSS.

    • import can only be recognized in IE5 or above, and link is an XHTML tag, so there is no compatibility issue;

    • When the page is loaded, link will are loaded at the same time, and the CSS referenced by @import

      will wait until the page is loaded before loading;

    • About priority

    • Things to note when using import: This rule must be declared first in the head of the style sheet. And the semicolon after it is required. If this semicolon is omitted, the external style sheet will not be imported correctly and

      error message will be generated.

    【Related recommendations】

    1.

    Free css online video tutorial

    2.

    css online manual

    3.

    php.cn Dugu Jiujian (2)-css video tutorial

The above is the detailed content of Summarize the differences between link and @import in loading css. For more information, please follow other related articles on 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!