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

              
                <main>
  
  <h1>Disabled button</h1>
  
  <p class="intro">
    HTML provide the standard 'disabled' attribute for interactive elements.
    But always using this attribute to indicate that an action is disabled
    can sometime hurt accessibility. This example tries to explain why.
  </p>
  
  <h2>
    Why you should use 'disabled'?
  </h2>
  <ul>
    <li>You get native action blocking when user tries to click.</li>
    <li>You get native style for button</li>
  </ul>

  <h2>
    Why should you not use 'disabled'?
  </h2>
  <ul>
    <li>Action do not participate anymore in <kbd>Tab</kbd> navigation.</li>
    <li>Action cannot get focus, which is blocking if you expose
        a tooltip on focus.
    </li>
  </ul>
  
  <p>
    It all depend on expected UX, but I think it's much better to
    <em>not</em> use HTML 'disabled' attribute and only specify disabled
    through 'aria-disabled'.
  </p>

  <h2>Demo</h2>

  <p>Using disabled:</p>
  <form>
    <button type="button" class="btn">Select 1</button>
    <button type="button" class="btn" disabled='disabled'
            data-bs-toggle="tooltip" data-bs-title="This option is not available">
      Select 2
    </button>
    <button type="button" class="btn">Select 3</button>
  </form>
  
  <p class="note">
    Note tooltip is not visible on disabled button.
    Official guideline from Bootstrap would be to wrap the button in a span, 
    but that imply that span must be able to gain focus.
  </p>

  <p>Using aria-disabled:</p>
  <form>
    <button type="button" class="btn">Select 1</button>
    <button type="button" class="btn">Select 2</button>
    <button type="button" class="btn" aria-disabled='true'
            data-bs-toggle="tooltip" data-bs-title="This option is not available">
      Select 3
    </button>
  </form>
  
  <p class="note">
    Note that you can navigate to disabled button with <kbd>Tab</kbd> key.
  </p>

</main>
              
            
!

CSS

              
                /* --- GLOBAL STYLE */

:root {
  --clr-grey-dark:       hsl(0, 0%, 10%);
  --clr-grey-dark-50:    hsla(0, 0%, 10%,  .5);
  --clr-grey-medium:     hsl(0, 0%, 50%);
  --clr-grey-medium-50:  hsla(0, 0%, 50%, .5);
  --clr-grey-light:      hsl(0, 0%, 95%);
  --clr-snow:            hsl(0, 90%, 98%);
  --clr-snow-50:         hsla(0, 90%, 98%, .5);
  --clr-blue-light:      hsl(210, 80%, 80%);
  --clr-intro-bg:        hsl(210, 60%, 80%);
  --clr-details:         hsl(170, 40%, 95%);
}

body {
  font-size: 18px;
  font-family: sans-serif;
  background-color: var(--clr-grey-dark);
  
  display: grid;
  min-height: 100vh;
}

main {
  margin: 0 auto;
  padding: .5rem;
  min-width: 40rem;
  max-width: 40rem;
  background-color: var(--clr-grey-light);
  min-height: 100%;
}

h1 {
  margin: 1rem 0 1rem;
}
h2 {
  margin: 3rem 0 2rem;
}

ul li {
  margin: .5rem 0 .5rem 0;
  line-height: 1.5rem;
}

*:focus,
.btn:focus {
  outline: unset;
}

kbd {
  color: var(--clr-grey-dark);
  background-color: var(--clr-grey-medium-50);
  padding: .1rem .5rem;
  border-radius: .2rem;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid var(--clr-grey-dark);
  border-bottom: 1px solid var(--clr-grey-dark);
}

*:focus-visible,
.btn:focus-visible,
.focused--outline {
  outline: 2px solid red !important;
  outline-offset: 2px;
}

.img-placeholder {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--clr-grey-dark);

  background-color: var(--clr-grey-dark);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--clr-grey-light) 50%);
  background-size: 2rem 2rem;
}

.capsule {
  display: inline-block;
  margin: .5rem auto -.5rem auto;
  padding: .25rem .5rem;

  border-radius: .3rem;
  background-color: var(--clr-blue-light);
}
.capsule.capsule--top {
  border-radius: .3rem .3rem 0 0;
}


.intro {
  margin: 2rem 1rem;
  padding: .5rem;
  
  font-size: .95rem;
  background-color: var(--clr-intro-bg);
  
  border-radius: .5rem;
}

.note {
  font-size: .9rem;
  padding: .5rem 0 .5rem 1rem;
  border-left: 4px solid var(--clr-grey-medium-50);
}

.btn {
  background: white;
  font-weight: bold;
  border: 2px solid var(--clr-grey-dark);
  border-radius: .5rem;
  padding: .5rem 1rem;
  margin: 1rem;
}

.btn:focus,
.btn:hover {
  box-shadow: 0px .25rem .2rem .1rem black;
}

.btn--disabled,
button[disabled],
button[aria-disabled=true] {
  background: var(--clr-grey-light);
  border-color: var(--clr-grey-dark-50);
  color: var(--clr-grey-dark-50);
  font-weight: normal;
  
  display: inline-flex;
  align-items: center;
}


              
            
!

JS

              
                const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
              
            
!
999px

Console