:nth-child(n) {
//CSS Property
}
<!DOCTYPE html>
<html>
<head>
<title>CSS :nth-child Selector</title>
<style>
p:nth-child(3n+4) {
background: yellow;
color: black;
font-size: 30px;
}
</style>
</head>
<body style="text-align:center">
<h1>
Hello World
</h1>
<h2>
Welcome to the lidihuo
</h2>
<p>It will not affected.</p>
<p>It will be affected.</p>
<p>Not affected.</p>
<p>Not affected.</p>
<p>It will be affected.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>CSS :nth-child Selector</title>
<style>
p:nth-child(even) {
background: yellow;
color: black;
font-size: 30px;
}
p:nth-child(odd) {
background: blue;
color: white;
font-size: 20px;
</style>
</head>
<body style="text-align:center">
<h1>
Hello World
</h1>
<h2>
Welcome to the lidihuo
</h2>
<p>Odd</p>
<p>Even</p>
<p>Odd</p>
<p>Even</p>
<p>Odd</p>
</body>
</html>