<header class="header">
  <div class="header__title">
    <h1>
      <code>not()</code>
    </h1>
  </div>
  <div class="header__reference">
    <ul class="reference-list">
      <li><a class="reference-list__link" href="https://developer.mozilla.org/en-US/docs/Web/CSS/:not">MDN reference</a></li>
      <li><a class="reference-list__link" href="https://caniuse.com/#feat=mdn-css_selectors_not">caniuse Support</a></li>
    </ul>
  </div>
</header>

<main>
  <div class="example">
    <p>
      In this example we are using the <code>not()</code> selector to apply a yellow outline to anything that is <strong>not</strong> a <code>p</code> element in the demo area. Notice that the selector targets not only each list item in the <code>ul</code> element, but also the <code>ul</code> element itself:
    </p>
    <div class="example__demo example__demo--not">
      <p>
        Oranges are round, orange-colored fruit that grow on trees. There are many different kinds of oranges, including: 
      </p>
      <ul>
        <li>Valencia</li>
        <li>Navel</li>
        <li>Clementine</li>
        <li>Cara Cara</li>
        <li>Lima</li>
      </ul>
      <p>
        Oranges are a commonly available source of Vitamin C, and last longer than many other fruits when stored. They are easy to transport because each orange comes in its own tough skin which acts as a container.
      </p>
      <img
        alt="A basket of oranges sitting in a red crate."
        src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/naomi-koelemans-633994-unsplash.jpg" />
      <p>Orange description taken from <a href="https://simple.m.wikipedia.org/wiki/Orange_(fruit)">Simple English Wikipedia</a>.
    </div>
  </div>

  <aside>
    <p>
      <small>Photo by <a href="https://unsplash.com/photos/QI5nFAUXWvM">Naomi Koelemans</a> on <a href="https://unsplash.com/">Unsplash</a>.</small>
    </p>
  </aside>  
</main>
// Demo
.example__demo--not :not(p) {
  outline: 0.25em solid var(--color-sand);
}


// Pen Setup
.example__demo--not {  
  a,
  p,
  ul {
    color: var(--color-cinder);
  }
  
  img {
    height: auto;
    margin-top: var(--size-epsilon);
    width: 100%;
  }
}
View Compiled

External CSS

  1. https://codepen.io/ericwbailey/pen/vMXWgz

External JavaScript

This Pen doesn't use any external JavaScript resources.