First: 4 ways to introduce CSS
There are 4 ways to introduce CSS: inline, inline, link, import style
1. Inline style
The most straightforward and straightforward one, use style= "" directly on HTML tags, for example:
<p style= "color: #F00; "></p>
Disadvantages: HTML page is not pure, file size, not conducive to spider crawling, late maintenance inconvenient.
2. Inline style
The inline style is to write the CSS code between
<style type= "Text/css" >
body,div,a,img,p{margin:0; padding:0;}
</style>
Advantages and Disadvantages: the page using public CSS code, but also each page to be defined, if a site has a lot of pages, each file will become larger, later maintenance difficulty is also large, if the file is very small, CSS code is not much, this style is still very good.
3. Link Style
Link style is the most frequently used, the most practical style, only need to add <link.../> between
<link type= "Text/css" rel= "stylesheet" href= "Style.css"/>
Advantages and Disadvantages: the implementation of the page framework code and performance of the CSS code completely separated, making pre-production and post-maintenance is very convenient
4. Import style (not recommended)
Import style and link style are similar, import CSS style sheet with @import style, when HTML is initialized, it will be imported into HTML or CSS file, become part of the file, similar to the second kind of inline style.
@import used in HTML, as follows:
<style type= "Text/css" >
@import URL (style.css);
</style>
@import used in CSS, as follows:
@import URL (style.css);
Second: Four ways to prioritize CSS introduction
1. Principle of proximity
2. Theoretically: inline > Inline > Link > Import
3. Actually: embed, link, import in the same file header, who is close to the corresponding code, who has high priority
4 ways to introduce and prioritize CSS