1. CSS in the tag. 2. CSS in the webpage. 3. CSS referenced by link. 4. Import the referenced CSS.
The source code is as follows:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> four methods for introducing CSS </title>
<Style type = "text/CSS">
/* H2 {color: White; Background-color: Blue ;}*/
/* To make CSS in the webpage take effect, you must comment out the next line of code */
@ Import "import.css ";
</Style>
<Link href = "alone.css" rel = "stylesheet" type = "text/CSS"/>
</Head>
<Body>
<H1 style = "color: White; Background-color: yellow"> CSS in the tag
<H2> CSS in the webpage </H2>
<H3> CSS file referenced by link
<H4> the CSS file referenced by import </H4>
<P> the difference between link reference and import reference is that link is referenced before HTML loading, and import is referenced only after HTML loading. For example, if impor is used for reference, a page without a style is displayed first, and then the style is put in. If CSS is dynamically referenced using JavaScript, you must use the link reference method. </P>
</Body>
</Html>
Import.css
@ Charset "UTF-8 ";
/* CSS document */
H4 {color: #000000; Background-color: #009900;
}
Alone.css
@ Charset "UTF-8 ";
H3 {color: White; Background-color: red ;}
/* CSS document */