Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Exploration of a visually hidden CSS mixin, an example for the <a href="https://kizu.dev/layered-toggles/" target="_blank">layered toggles</a> article</h1>
<p>Thought about it after reading <a href="https://cssence.com/2024/native-visually-hidden/" target="_blank">Native visually hidden</a> post by <a href="https://cssence.com/" target="_blank">Matthias Zöchling</a>. The mixin is based on the code from <a href="https://benmyers.dev/blog/native-visually-hidden/" target="_blank">The Web Needs a Native .visually-hidden</a> post by <a href="https://benmyers.dev/" target="_blank">Ben Myers </a></p>
<ul>
  <li>This item contains a visually-hidden element between the quotes: “<span style="--visually: var(--hidden)">this text is visually hidden</span>”, using an inline style.</li>
  <li>This paragraph contains a visually-hidden button: <button class="visually-hidden">this button is visually hidden</button>, it should be possible to show it by moving the focus on it.</li>
</ul>
<p>This is an experimental technique and relies on @layer support.</p>
              
            
!

CSS

              
                .visually-hidden {
  --visually: var(--hidden);
}

*:not(:focus):not(:active) {
  @layer {
    --visually: var(--not-hidden);
  }
  /* Ideally we'd want a longer name for a bette namespacing, these are short for the demo. */
  --hidden: var(--visually,);
  --not-hidden: var(--visually,);
  
  @layer {
    border:
      var(--hidden, 0)
      var(--not-hidden, revert-layer);
    clip:
      var(--hidden, rect(0 0 0 0))
      var(--not-hidden, revert-layer);
    clip-path:
      var(--hidden, inset(50%))
      var(--not-hidden, revert-layer);
    height:
      var(--hidden, 1px)
      var(--not-hidden, revert-layer);
    margin:
      var(--hidden, -1px)
      var(--not-hidden, revert-layer);
    overflow:
      var(--hidden, hidden)
      var(--not-hidden, revert-layer);
    padding:
      var(--hidden, 0)
      var(--not-hidden, revert-layer);
    position:
      var(--hidden, absolute)
      var(--not-hidden, revert-layer);
    white-space: 
      var(--hidden, nowrap)
      var(--not-hidden, revert-layer);
    width:
      var(--hidden, 1px)
      var(--not-hidden, revert-layer);
  }
}


              
            
!

JS

              
                
              
            
!
999px

Console