:第N-子(N):n番目のサブ要素の親要素
:N次の式(N) :親要素特定の n番目のサブ要素
注:nは1以降から要素インデックス、以降0であります
n番目の子(n)はn番目の和-の型(n)の例:
<head>
<style>
body :nth-child(2) {
height: 30px;
background: blue;
color: #fff;
}
</style>
</head>
<body>
<p>1 - p1</p>
<div>2 - div1</div>
<p>3 - p2</p>
<div>4 - div2</div>
</body>
また:n番目の子として:n番目の-の型
<style>
body :nth-of-type(2) {
height: 30px;
background: blue;
color: #fff;
}
</style>