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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

              <a href="#" class="button js-button" role="button">Show content</a>

<div class="content">
  <p>This demonstrates how to markup an <code>&lt;anchor&gt;</code> element as if it were a <code>&lt;button&gt;</code> element.</p>
  <p>Key takeaway is to add <code>role="button"</code> and handle the 'space' key as native buttons will excecute JS events on 'space' keypress by default.</p>
              body {
  padding: 2em;

.button {
  background-color: ForestGreen;  
  border-radius: 5px;
  color: white;
  padding: .5em;
  text-decoration: none;

.button:hover {
  background-color: DarkGreen;

.content {
  display: none;
  margin: 1em 0;

.no-js .content {
  display: block;
              (function (document, window, undefined) {
  'use strict';
  // Buttons
  var buttons = document.querySelectorAll('.js-button');   
  var displayContent = function (button, content) {
    if (content.classList.contains('active')) {
        // Hide content
        button.setAttribute('aria-expanded', 'false');
        content.setAttribute('aria-hidden', 'true');
      } else {
        // Show content
        button.setAttribute('aria-expanded', 'true');
        content.setAttribute('aria-hidden', 'false');
  [].forEach.call(buttons, function(button, index) {
    // Content var
    var content = button.nextElementSibling;
    // Set button attributes
    button.setAttribute('id', 'button-' + index);
    button.setAttribute('aria-expanded', 'false');
    button.setAttribute('aria-controls', 'content-' + index);
    // Set content attributes
    content.setAttribute('id', 'content-' + index);
    content.setAttribute('aria-hidden', 'true');    
    content.setAttribute('aria-labelledby', 'button-' + index);
    button.addEventListener('click', function () {
      displayContent(this, content);
      return false;
    }, false);
    button.addEventListener('keydown', function (event) {
      // Handle 'space' key
      if (event.which === 32) {
        displayContent(this, content);
    }, false);
})(document, window);
Loading ..................