not pseudo-class
This pseudo-class is used to select elements that do not match a specific selector.
Example: In the following example, the :not pseudo-class is used to select all h1 elements that do not have the class “special”. The color of these h1 elements will be set to green.
<!DOCTYPE html>
<html>
<head>
<title>:not Pseudo-class Example</title>
<style>
h1:not(.special) {
color: green;
}
</style>
</head>
<body>
<h1 class>w3wiki</h1>
<h2>:not Pseudo-class</h2>
<h1 class="special">Special Header</h1>
</body>
</html>
Output:
CSS Pseudo-classes
CSS Pseudo-classes are powerful and allow developers to style elements based on their specific states. This guide will walk you through the most commonly used pseudo-classes and how to use them effectively.
Pseudo-classes in CSS are used to define the special state of an element. They can be combined with a CSS selector to add an effect to existing elements based on their states. For instance, you can change the style of an element when the user hovers over it, or when a link is visited. All of these can be achieved using Pseudo Classes in CSS.
Note that pseudo-class names are not case-sensitive.
Syntax:
selector: pseudo-class{
property: value;
}
There are many Pseudo-classes in CSS but the ones that are most commonly used are as follows:
Contact Us