标签样式
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
/*标签样式*/
p{
color:red
}
</style>
</head>
<body>
<p>这是段落一</p>
<p >这是段落一</p>
<p >这是段落一</p>
</body>
</html>
类样式
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
/*类样式*/
.f20{
font-size:20px;
}
</style>
</head>
<body>
<p class="f20">这是段落一</p>
</body>
</html>
ID样式
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
/*ID样式*/
#f30{
background-color:pink;
font-size:24px;
font-weight:bolder;
font-style:italic;
font-family:"华文彩云";
}
</style>
</head>
<body>
<p id="f30">这是段落一</p>
</body>
</html>
组合样式
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
/*组合样式*/
div p{
color:yellow;
}
div .f32{
font-size:32px;
font-family:"黑体";
}
</style>
</head>
<body>
<div>
<p><span style="font-size:60px;font-weight:bolder;color:yellow;">HELLO</span></p>
<span calss="f32">World</span>
<p class="f32">!!!</p>
</div>
</body>
</html>
嵌入式样式表
内部样式表
<p><span style="font-size:60px;font-weight:bolder;color:yellow;">HELLO</span></p>
外部样式表
将样式写在css文件内,在html文件中导入css文件
/*ID样式*/
#f30{
background-color:pink;
font-size:24px;
font-weight:bolder;
font-style:italic;
font-family:"华文彩云";
}
/*组合样式*/
div p{
color:yellow;
}
div .f32{
font-size:32px;
font-family:"黑体";
}
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/demo01.css">
</head>
<body>
<p>这是段落一</p>
<p class="f20">这是段落一</p>
<p id="f30">这是段落一</p>
<div>
<p><span style="font-size:60px;font-weight:bolder;color:yellow;">HELLO</span></p>
<span calss="f32">World</span>
<p class="f32">!!!</p>
</div>
</body>
</html>