在HTML中引入CC有好几种方法,按优先级排列分别是:1、行内式,2、嵌入式,3、导入式和链接式
在HTML中引入CSS的方法有以下几种:
1)行内式
比如:
<body>
<h1 style="color:white;background-color:blue">
This is a line of Text.
</h1>
</body>
2)嵌入式
比如:
<head>
<style type="text/css">
h1 {
color: white;
background-color: blue
}
</style>
</head>
<body>
<h1>This is a line of Text.</h1>
<h1>This is another line of Text.</h1>
</body>
3)导入式和链接式
先要把CSS的内容写到一个.CSS的文件中
比如:
mycss.css
h1{
color:white;background-color:blue
}
导入式写法(注意CSS文件的路径要正确):
<head>
<style type="text/css">
@import"mycss.css";
</style>
</head>
<body>
<h1>This is a line of Text.</h1>
<h1>This is another line of Text.</h1>
</body>
链接式写法(注意CSS文件的路径要正确):
<head>
<link href="mycss.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h1>This is a line of Text.</h1>
<h1>This is another line of Text.</h1>
</body>
本文详细介绍了HTML中引入CSS的四种方法:行内式、嵌入式、导入式和链接式,包括具体语法和使用场景。
426

被折叠的 条评论
为什么被折叠?



