Original address
Use the Style property of the HTML tag
Each HTML tag has a property on it: Style, which combines CSS and HTML
Example: Set the font background color to red and the font color to yellow.
<!DOCTYPE html> <meta charset="utf-8"/> <title>结合方式一</title> <body> <div style="background-color: red;color: yellow;">hjwblog.com</div> </body>
Use the HTML style label
This label is written in the label.
Example:
<! DOCTYPEHtml> <metacharset="Utf-8" /> <title>Combination Mode Two</title> <styletype="Text/css">Div{ Background-color: Blue; Color: Yellow; } </style> <body> <div>Hjwblog.com</div> </body>
Inside the style tag @importFirst create a CSS file, here is mycss.css
, under the CSS folder.
/* * 这是注释 */div{ background-color: yellow; color: blue;}
And then HTML writes like this
<! DOCTYPE html> <HTML> <meta charset= "Utf-8" span class= "kw" >/> <TITLE> combined mode three </TITLE> <style type= "TEXT/CSS" > @import url ( "CSS/MYCSS.CSS" ) </STYLE> </HEAD> <BODY> <DIV> hjwblog.com</DIV> </body </HTML>
Using the header Tag linkUsing <link>
Labels
<!DOCTYPE html>"utf-8" /> <title>结合方式四</title> <link rel="stylesheet" type="text/css" href="css/mycss.css"/>
AttentionThe third way in some browsers does not display normally, generally in the fourth way.
Four ways to combine CSS with CSS and HTML