Examples
by Adhik Bagul
HTML
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/:not -->
<p>I am a paragraph.</p>
<p class="fancy">I am so very fancy!</p>
<p class="fancy">I am a paragraph green.</p>
<div>I am NOT a paragraph.</div>
CSS
.fancy {
text-shadow: 2px 2px 3px gold;
}
/* <p> elements that are not in the class `.fancy` */
p:not(.fancy) {
color: green;
}
/* Elements that are not <p> elements */
body :not(p) {
text-decoration: underline;
}
/* Elements that are not <div> and not <span> elements */
body :not(div):not(span) {
font-weight: bold;
}
/* Elements that are not `.crazy` or `.fancy` */
/* Note that this syntax is not well supported yet. */
body :not(.crazy, .fancy) {
font-family: sans-serif;
}