Interview Question

What is nth-of-type selector?

`nth-of-type()` counts only siblings with the same element type.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

The `:nth-of-type()` pseudo-class matches elements by position among siblings of the same type. • Other sibling element types do not affect its count. • It accepts the same An+B syntax as `:nth-child()`. • It is based on element type, not class name.

💡 Simple Example

p:nth-of-type(2) { font-weight: 700; }

⚡ Quick Revision

`nth-of-type()` counts only siblings with the same element type.