cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <h1>:not Pseudo-class or Negation?</h1>

<h2>:not Pseudo-class</h2>
<p>We could see that the "Send" and "Search" buttons have been styled with a blue background except for the "Like / Heart" button - because of the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/%3Anot">:not pseudo-class</a>.</p>

<div class="message">
    <textarea></textarea>
    <button class="message-button"><span>Send</span></button>
</div>

<div class="search">
    <input>
    <button class="search-button">
        <span>Search</span>
        <svg class="icon icon-search"><use xlink:href="#icon-search"></use></svg>
    </button>
</div>

<div class="like">
    <p>Hello, world!</p>
    <button class="like-button">
        <span>Like</span>
        <svg class="icon icon-heart"><use xlink:href="#icon-heart"></use></svg>
    </button>
</div>

<h2>Negation</h2>
<p>The "Home" button, on the other hand, needs to be negated from the style of the generic <code>button</code> selector. We remove its blue background color and white foreground color.</p>

<div class="home">
    <p>Go home!</p>
    <button class="home-button">
        <span>Home</span>
        <svg class="icon icon-home"><use xlink:href="#icon-home"></use></svg>
    </button>
</div>

<h1>Use Negation</h1>
<p>If you are using the object-oriented approach in structuring the CSS, you would use negation instead of :not pseudo-class. When using the :not pseudo-class, two focuses are at hand: the selector itself and the excluded selector. And the excluded selector could be easily lost within the selector itself.</p>
<p>If you really need to declare styles on a generic selector, negate the other selectors with unintended styles.</p>





<!------ SVG Icons ------>
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-search" viewBox="0 0 32 32">
<title>search</title>
<path d="M31.008 27.231l-7.58-6.447c-0.784-0.705-1.622-1.029-2.299-0.998 1.789-2.096 2.87-4.815 2.87-7.787 0-6.627-5.373-12-12-12s-12 5.373-12 12 5.373 12 12 12c2.972 0 5.691-1.081 7.787-2.87-0.031 0.677 0.293 1.515 0.998 2.299l6.447 7.58c1.104 1.226 2.907 1.33 4.007 0.23s0.997-2.903-0.23-4.007zM12 20c-4.418 0-8-3.582-8-8s3.582-8 8-8 8 3.582 8 8-3.582 8-8 8z"></path>
</symbol>
    <symbol id="icon-heart" viewBox="0 0 32 32">
<title>heart</title>
<path d="M23.6 2c-3.363 0-6.258 2.736-7.599 5.594-1.342-2.858-4.237-5.594-7.601-5.594-4.637 0-8.4 3.764-8.4 8.401 0 9.433 9.516 11.906 16.001 21.232 6.13-9.268 15.999-12.1 15.999-21.232 0-4.637-3.763-8.401-8.4-8.401z"></path>
</symbol>
    <symbol id="icon-home" viewBox="0 0 32 32">
<title>home</title>
<path d="M32 18.451l-16-12.42-16 12.42v-5.064l16-12.42 16 12.42zM28 18v12h-8v-8h-8v8h-8v-12l12-9z"></path>
</symbol>
</defs>
</svg>
            
          
!
            
              /* ------ Using :not ------ */
button:not( .like-button )
{
    /* Reset */
    margin: 0;
    padding: 0;
    border: 0;
    background-color: transparent;

    /* Style */
    padding: .75em 1.25em;
    background-color: blue;
    color: white;
}

/* ------ Using negation ------ */
.home button
{
    padding: 0;
    background-color: transparent;
    color: gray;
}

/* ------ Ignore these styles ------ */

input,
button
{
    display: block;
}

div
{
    padding: 1em;
}

/* Space correction */
textarea
{
    margin-bottom: -5px;
}

.search .icon,
.like .icon,
.home .icon
{
    width: 1.5em;
    height: 1.5em;
}

/* icomoon.io */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    stroke-width: 0;
    stroke: currentColor;
    fill: currentColor;
}

button
{
    
}

.search button span,
.like button span,
.home button span
{
    display: none;
}

html
{
    font-family: sans-serif;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console