There are three ways to embed CSS in HTML: embedded, inline, and quoted.
First, embedded
Use the style element in your HTML document to define CSS styles.
1 <Head>2 <styletype= "Text/css">3 H1{Color:Red}4 H2{Color:Blue}5 </style>6 </Head>
Two, inline type
The Style property can be defined in each element of the HTML, and this property can only work on this element. does not work for other elements.
1 < style= "color: #FFF; font-size:20;" > Entry Dog Blog Park </p>
Iii. quoted type
1. Using processing instructions
1 <? xml-stylesheet type= "text/css" href= "Css.css " ?> 2 < HTML > 3 < P > Entry Dog Blog Park </p>4</HTML >
The browser loads the Css.css file when it is rendered, but most of the browsing is only useful if the file is saved as. xhtml or. xml format and is not recommended.
2. Using the @import directive
1 < style > 2 /* The following two effects are the same */ 3 @import "Css.css"4 @import url ("Css.css"); 5 </ style >
3. Using the LINK element
1 < Head > 2 < href= "Css.css" rel= "stylesheet" type= "Text/css" >3</head>
This is the most common method, the href attribute specifies the URL of the style sheet, followed by the designation rel= "stylesheet" type= "Text/css".
4. Linking to a style sheet using the HTTP message header
1 Link: (css.css) rel= "stylesheet"2 equivalent to 3<href = "Css.css" rel= "stylesheet" type= "Text/css">
The link field of the HTTP header has a higher precedence than the link field in the HTML document.
Several methods of embedding CSS in HTML documents