一、三大基本选择器
- ⭐标签名(元素)选择器
- ⭐ID选择器
- ⭐类(class)选择器
<html>
<head>
<meta charset="utf-8">
<title>基本选择器</title>
<style type="text/css">
span{
font-size: 20px;
color: #8A2BE2;
background-color: black;
font-family: "楷体";
}
#p1{
font-size: 22px;
color: #FFFF00;
background-color: #696969;
width: 250px;
height: 100px;
}
.c1{
font-size: 28px;
color: aqua;
background-color: cadetblue;
width: 300px;
text-decoration: none;
}
</style>
</head>
<body>
<span id="s1">今天是个上分的好日子</span>
<br>
<span id="s2">今天是个上分的好日子</span>
<p id="p1" class="pc1">今天是个上分的好日子</p>
<p id="p2" class="pc2">今天是个上分的好日子</p>
<p id="p3" class="c1">今天是个上分的好日子</p>
<a href="#" class="c1">百度</a>
</body>
</html>
二、其他选择器
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d01bf3c32daf0b65fa9d1ce701150c93.png)
<html>
<head>
<meta charset="utf-8">
<title>其他选择器</title>
<style type="text/css">
p font span{
color: red;
}
.i[type="password"]{
width: 300px;
height: 50px;
}
#ha,h2,.s2,p{
color: #00FFFF;
}
</style>
</head>
<body>
<span id="p1">今天是上分的好日子</span>
<p>
<span>今天是上分的好日子</span><br>
<font>
<span class="sc1">今天是上分的好日子</span>
</font>
</p>
<input type="text" class="i"/><br>
<input type="password" class="i"/><br>
<input type="password" class="i"/><br>
<input type="password" class="i"/><br>
<h1 id="ha">今天是上分的好日子</h1>
<h2 class="ch">今天是上分的好日子</h2>
<span class="s2">今天是上分的好日子</span>
<p id="pa">今天是上分的好日子</p>
</body>
</html>
三、伪类选择器
<html>
<head>
<meta charset="utf-8">
<title>伪类选择器</title>
<style type="text/css">
#a1:link{
color: #000000;
font-size: 30px;
text-decoration: none;
background-color: #8A2BE2;
}
a:visited{
color: #696969;
background-color: #5F9EA0;
}
a:hover{
color: #FF0000;
background-color: #000000;
}
a:active{
color: #8A2BE2;
background-color: #000000;
}
div{
border: 1px solid red;
width: 200px;
height: 200px;
background-color: #FFFF00;
}
div:hover{
background-color: #FF0000;
}
</style>
</head>
<body>
<a href="https://www.baidu.com" id="a1">百度</a>
<div ></div>
</body>
</html>