Syntax error Style every element that is not the specified element with CSS

Style every element that is not the specified element with CSS



To style every element that is not the specified element, use the CSS :not(selector) selector.

Example

You can try to run the following code to implement the :not selector:

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         p {
            color: red;
         }
         :not(p) {
            color: blue;
         }
      </style>
   </head>
   <body>
      <h1>Heading 1</h1>
      <h2>Heading 2</h2>
      <h3>Heading 3</h3>
      <p>This is a paragraph.</p>
      <p>This is another paragraph.</p>
   </body>
</html>
Updated on: 2020-07-01T09:19:46+05:30

143 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements