CSS Selector :not








The negation selector lets you invert any selection. This selector is added in CSS3. It has the following format:

not(selector)

Summary

CSS Version
3

CSS Syntax

:not(selector) {
   style properties 
}

Browser compatibility

:not(selector) Yes 9.0 Yes Yes Yes




Example

An example showing how to use :not CSS selector.

<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
        <style type="text/css"> 
        a:not([href*="java2s"]) { 
            border: thin black solid; 
            padding: 4px; 
        } <!--   w  w w  .  j a  v a2s.com-->
        </style> 
    </head> 
    <body> 
        <a href="http://java2s.com">Visit the java2s.com</a> 
        <a href="http://w3c.org">Visit the W3C website</a> 
    </body> 
</html>

Click to view the demo