HTML: four methods for importing CSS

Source: Internet
Author: User

In HTML, there are four methods to introduce CSS: inline, embedded, imported, and linked.
1. inline style: Set the CSS style in the marked style attribute. This method does not reflect the advantages of CSS in nature, so it is not recommended.
2. Embedded: the setting of various elements on the page is concentrated between 3. Import: the import format is as follows:
<Style type = "text/CSS">
@ Import "mystyle.css ";
</Style>
4. connector: format:
<Link href = "mystyle.css" rel = "stylesheet" type = "text/CSS"/>
The Display Effect of the last two methods is slightly different. The differences are as follows:
Connector: the CSS file is loaded before the page body is loaded, so that the displayed webpage has a style effect from the beginning;
Imported: the CSS file is loaded after the entire page is loaded. For Some browsers, if the size of the webpage file is large, A page with no style is displayed, and the effect after the style is set is displayed. This is a defect of the pilot type from the perspective of the viewer.
For some large websites, in order to facilitate maintenance, you may want to put all CSS styles into several CSS files by category. If you use a connector, several statements are required to import the CSS file. If you want to adjust the classification of CSS files, you need to adjust the HTML files at the same time. This is a defect in the maintenance work. If you use the pilot type, you can only introduce one total CSS file, import other independent CSS files in this file, but the connection does not have this feature.
Therefore, we recommend that you use the connection method if you only need to introduce one CSS file. If you need to introduce multiple CSS files, first, introduce a "directory" CSS file using the connection method. In this "directory" CSS file, use the pilot method to introduce other CSS files.
If you want to use JavaScript to dynamically decide which CSS file to introduce, you must use a connector.

 

Link: http://hi.baidu.com/noahsark7/blog/item/3e5488b467f9bc7b8bd4b22f.html

 

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.