CSS元素选择器
CSS ID选择器
CSS CLASS选择器
CSS通用选择器
CSS组选择器
<!DOCTYPE html>
<html>
<head>
<style>
p{
text-align: center;
color: blue;
}
</style>
</head>
<body>
<p>此样式将应用于每个段落。</p>
<p id="para1">我也是!</p>
<p>还有我!</p>
</body>
</html>
此样式将应用于每个段落。
我也是!
还有我!
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<p id="para1">您好 bianchenghao6.com。</p>
<p>此段不会受到影响。</p>
</body>
</html>
您好bianchenghao6.com。
此段不会受到影响。
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1 class="center">此标题是蓝色且居中对齐。</h1>
<p class="center">此段落为蓝色且居中对齐。</p>
</body>
</html>
此段落为蓝色且居中对齐。
<!DOCTYPE html>
<html>
<head>
<style>
p.center {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1 class="center">此标题不受影响。</h1>
<p class="center">此段落是蓝色且居中对齐。</p>
</body>
</html>
此段落是蓝色且居中对齐。
<!DOCTYPE html>
<html>
<head>
<style>
* {
color: green;
font-size: 20px;
}
</style>
</head>
<body>
<h2>这是标题。</h2>
<p>此样式将应用于每个段落。</p>
<p id="para1">我也是!</p>
<p>还有我!</p>
</body>
</html>
此样式将应用于每个段落。
我也是!
还有我!
h1 {
text-align: center;
color: blue;
}
h2 {
text-align: center;
color: blue;
}
p {
text-align: center;
color: blue;
}
h1,h2,p {
text-align: center;
color: blue;
}
<!DOCTYPE html>
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1>Hello bianchenghao6.com</h1>
<h2>Hello bianchenghao6.com (较小的字体)</h2>
<p>这是一个段落。</p>
</body>
</html>
这是一个段落。