Discussion on the difference and usage of CSS and @import

Source: Internet
Author: User
The following small series for everyone to bring a brief talk about CSS and @import differences and usage. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.

Both CSS and @import are methods that call external style sheets.

First, usage

(1) Link:

<link rel= "stylesheet" type= "Text/css" href= "CSS file path"/>

(2) @import:

Method one (added in HTML):

<style type= "Text/css" >

@import url (CSS file path);

</style>

Method Two (added in CSS):

@import url (CSS file path);

Second, the difference

(1) Link is an XHTML tag that, in addition to loading CSS, can also define other transactions such as RRs. @import belong to the CSS category, only CSS can be loaded.

(2) Link refers to the CSS style, is loaded synchronously with the page load, @import is loaded after the page loads.

(3) Link is XHTML label, no compatibility problem, @import is proposed in CSS2.1, the lower version of the browser is not supported.

(4) Link supports the use of JavaScript to control the DOM to change styles, while @import is not supported.

The above discussion of the CSS and @import differences and usage is the small part of the whole content to share to everyone, I hope we can give you a reference, but also hope that we support a lot of topic.alibabacloud.com.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.