<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
ul li:first-child{
background: cyan;
}
ul li:last-child{
background: coral;
}
p:nth-child(2){
background: chartreuse;
}
/*p:nth-child(1){*/
/* background: aquamarine;*/
/*}*/
p:nth-of-type(2){
background: yellow;
}
</style>
</head>
<body>
<h1>h1</h1>
<p>p1</p>
<p>p2</p>
<p>p3</p>
<ul>
<li>li1</li>
<li>li2</li>
<li>li3</li>
</ul>
</body>
</html>
CSS structured pseudo-class selector
Guess you like
Origin blog.csdn.net/m0_45311187/article/details/112658202
Recommended
Ranking