The introduction of CSS in HTML mode

There are four ways to introduce CSS in HTML. There are two ways in which the CSS code is added directly in the HTML file, is introduced into the other two external CSS files.

 

(I) within the United way

Inline refers directly in the HTML tag  style attribute added CSS.

 

(Ii) embeds

Mode refers to the embedding HTML header  <style> Writing CSS code label.

 

 

(Iii) the link mode

Chaining mode refers to the use of HTML header  <head> tag introduced external CSS files.

 

 

(Iv) Import mode

Import mode refers to the use of CSS rules to import external CSS file.

 

 

Compare chaining mode and import

Link mode (instead of following a link) and Import mode (below using  @import substitute) are introduced into an external CSS file the way, let's compare these two methods.

  • link belong to HTML, through  to the introduction of an external file <link> tag href attribute, and  @import CSS belong, so the import statement should be written in CSS, should be noted that the import statement should be written at the beginning of the style sheet, or can not properly import external files;

  • @import is a concept only appeared CSS2.1, so if your browser version is low, can not import an external style file correctly;

  • When the HTML file is loaded, link referenced file will also be loaded, and  @import referenced file will be downloaded again and so on all the pages are loaded;

 

Reference: Rookie notes

       I hope that helps.

Guess you like

Origin www.cnblogs.com/shihaiying/p/11294309.html