क्लास सेलेक्टर (Class Selector)
HTML में class एट्रिब्यूट के आधार पर स्टाइल रूल्स डिफाइन करें। क्लास सेलेक्टर के लिए डॉट (.) फिर क्लास नाम लिखें, जैसे .black।
.black { color: #000000; }
केवल <h3> एलिमेंट्स जिनमें class="black" हो, के लिए:
h3.black { color: #000000; }
उदाहरण: <p> टैग स्टाइलिंग
<!DOCTYPE html> <html>
<head>
<style>
p.device { background: #000000; color: #ffffff; }
</style>
</head>
<body>
<p>This is demo text</p>
<p class="device">Information about devices.</p>
<p>This is demo text</p>
</body>
</html>
उदाहरण: मल्टीपल क्लासेस
<!DOCTYPE html> <html>
<head>
<style>
p.device { background: #000000; color: #ffffff; }
p.accessories { text-align: center; }
</style>
</head>
<body>
<p class="device accessories">DEVICE DETAILS</p>
<p class="device">Information about devices.</p>
</body>
</html>