Four ways to introduce CSS

Source: Internet
Author: User
The introduction of CSS is the most commonly used in three kinds,

First: Add the <link rel= "stylesheet" type= "Text/css" href= "My.css" in the head section, and import the external CSS file.

This approach can be said to be the dominant method of introduction now. Like IE and browser. This is also the best way to embody the characteristics of CSS, the best embodiment of div+css content and display separation of ideas, but also the most easy to revise the maintenance, code seems to be the most beautiful one.

Second: Add in the head section
<style type= "Text/css" >
DIV{MARGIN:0;PADDING:0;BORDER:1PX red Solid;}
</style>

The use of this method is much less, the longest seen is a large number of access to the portal site. or the first page of an enterprise website with a large number of visits. Compared with the first method, the advantages are outstanding and the drawbacks are obvious. Advantages: Fast, all the CSS control is for this page label, there is no extra CSS commands, and not the outside of the chain of CSS files. Reads the style directly in the HTML document. The drawback is that the revision of the trouble, a single page appears bloated, CSS can not be other HTML references caused by a relatively large amount of code, maintenance is also troublesome. But companies that use this approach are mostly rich, and for them the user volume is the key, and they are not short of complicated maintenance work.

Third: Add <div style= "border:1px red solid" directly in the label of the page. > Test Information </div>

This approach is rarely used, and many companies do not understand the leadership of the front-end technology is also very hate this writing. The CSS command cannot be found in HTML. In fact, sometimes the use of the next is not a big deal. For example, the versatility is poor, the effect is special, using the CSS command less, and the place that does not change frequently, use this method is a good choice instead.

In addition to these three commonly used CSS introduction way, there is a lot of people have not seen the introduction of the way
<style type= "Text/css" >
@import URL (my.css);
</style>

This is the fourth method of introduction. When working at IBM, you can use only one AJAX framework, which is dojo. The CSS reference of dojo is the @import way. This is a very small situation, mainly used in a large number of CSS files in the responsible system. In addition @important itself is a CSS command, is placed in the CSS file, this and link tag has a very big difference.


Related Article

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.