:first-of-type सेलेक्टर का उपयोग
:first-of-type सेलेक्टर अपने पैरेंट के अंदर **अपने टाइप का पहला** एलिमेंट को सिलेक्ट करता है। यह :first-child से अलग है जो किसी भी टाइप के पहले चाइल्ड को चुनता है।
उदाहरण
<!DOCTYPE html>
<html>
<head>
<style>
p:first-of-type {
background: orange;
}
</style>
</head>
<body>
<p>This is demo text1.</p>
<p>This is demo text2.</p>
</body>
</html>
यहां पहला <p> स्टाइल होगा, भले ही उसके पहले कोई <h1> या अन्य टैग हो।