प्सूडो-क्लास
एक प्सूडो-क्लास सेलेक्टर की एक अवस्था को दर्शाता है जैसे :hover, :active, :last-child, आदि। ये सिंगल कोलन (:) से शुरू होते हैं।
CSS प्सूडो-क्लास का सिंटैक्स निम्नानुसार है:
:pseudo-class{ attribute: /*value*/ }
प्सूडो-एलिमेंट
इसी तरह, एक प्सूडो-एलिमेंट वर्चुअल एलिमेंट्स को चुनने के लिए उपयोग किया जाता है जैसे ::after, ::before, ::first-line, आदि। ये डबल कोलन (::) से शुरू होते हैं।
CSS प्सूडो-एलिमेंट का सिंटैक्स निम्नानुसार है:
::pseudo-element{ attribute: /*value*/ }
उदाहरण 1 (प्सूडो-क्लास: होवर)
निम्न उदाहरण CSS प्सूडो-क्लास और प्सूडो-एलिमेंट प्रॉपर्टी को दर्शाते हैं।
<!DOCTYPE html> <html> <head> <style> a:hover{ padding: 3%; font-size:1.4em; color: tomato; background: bisque; } </style> </head> <body> <p>You're somebody else</p> <a href=#>Dummy link 1</a> <a href=#>Dummy link 2</a> </body> </html>
आउटपुट
यह निम्न परिणाम उत्पन्न करेगा:

उदाहरण 2 (प्सूडो-एलिमेंट: आफ्टर और लास्ट-चाइल्ड)
<!DOCTYPE html> <html> <head> <style> p::after { content: " BOOM!"; background: hotpink; } p:last-child { font-size: 1.4em; color: red; } </style> </head> <body> <p>Anymore Snare?</p> <p>Donec in semper diam. Morbi sollicitudin sed eros nec elementum. Praesent eget nisl vitaeneque consectetur tincidunt. Ut molestie vulputate sem, nec convallis odio molestie nec.</p> <p>Hit</p> <p>Pop</p> </body> </html>
आउटपुट
यह निम्न परिणाम उत्पन्न करेगा:
