:nth-of-type(n)





css/style.css
  • /*number (2); formula (2n+0), keyword(odd), keyword(even)*/
  • p:nth-of-type(2) {
  •  color: #00F;
  •  font-size: 18px;
  • }
/*number (2); formula (2n+0), keyword(odd), keyword(even)*/
p:nth-of-type(2) {
 color: #00F;
 font-size: 18px;
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  • </head>
  • <body>
  •  <div>
  •   <p>Hello World!</p>
  •   <p>To be or not to be?</p>
  •   <p>Привет Мир!</p>
  •  </div>
  •  <hr />
  •  <div>
  •   <p>One</p>
  •   <p>Two</p>
  •   <p>Three</p>
  •  </div>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  • </head>
  • <body>
  •  <div>
  •   <p>Hello World!</p>
  •   <p>To be or not to be?</p>
  •   <p>Привет Мир!</p>
  •  </div>
  •  <hr />
  •  <div>
  •   <p>One</p>
  •   <p>Two</p>
  •   <p>Three</p>
  •  </div>
  • </body>
  • </html>