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.

            
              <article>
    <h1>Button Pal</h1>
    <p>You get so much <i>for free</i> when you use a real button, so here's a block of CSS to remove the headache of styling them for you. Read more about why you should use a button <a href="https://css-tricks.com/small-tweaks-can-make-huge-impact-websites-accessibility/#article-header-id-2" target="_blank" rel="noopener">here</a>.</p>
    <h2>The button</h2>
    <p>Check out this totally workable button. It's pretty much as easy to work with as a <code>&lt;div&gt;</code>. You can share these styles with an <code>&lt;a&gt;</code> too 🚀</p>
    <button>Oh hey, I'm your Pal, a button</button>
    <div role="status"></div>
    <h2>The code</h2>
    <pre><code>button {
    display: inline-block;
    border: none;
    padding: 1rem 2rem;
    margin: 0;
    text-decoration: none;
    background: #0069ed;
    color: #ffffff;
    font-family: sans-serif;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background 250ms ease-in-out, 
                transform 150ms ease;
    -webkit-appearance: none;
    -moz-appearance: none;
}

button:hover,
button:focus {
    background: #0053ba;
}

button:focus {
    outline: 1px solid #fff;
    outline-offset: -4px;
}

button:active {
    transform: scale(0.99);
}</code></pre>
    <footer>
        <p>If you find this useful, you should probably check out <a href="https://boilerform.design" target="_blank" rel="noopener">Boilerform</a> to make your forms easier too.</p>
    </footer>
</article>
            
          
!
            
              
/* Buttons styles start */
button {
    display: inline-block;
    border: none;
    padding: 1rem 2rem;
    margin: 0;
    text-decoration: none;
    background: #0069ed;
    color: #ffffff;
    font-family: sans-serif;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    text-align: center;
    transition: background 250ms ease-in-out, transform 150ms ease;
    -webkit-appearance: none;
    -moz-appearance: none;
}

button:hover,
button:focus {
    background: #0053ba;
}

button:focus {
    outline: 1px solid #fff;
    outline-offset: -4px;
}

button:active {
    transform: scale(0.99);
}
/* Button styles end */






/* Ignore these presentational styles */
html {
    height: 100%;
}

body {
    height: 100%;
    display: grid;
    place-items: center;
    background: #f3f3f3;
    font-family: -apple-system, BlinkMacSystemFont, 
                    "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", 
                    "Fira Sans", "Droid Sans", "Helvetica Neue", 
                    sans-serif;
    line-height: 1.5;
    color: #333;
}

article {
    max-width: 60ch;
    padding: 2rem 1rem;
}

> * + *:not(pre) {
    margin: 1rem 0 0 0;
}

h1, h2 {
    font-weight: 300;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

h2 {
    padding-top: 0.5rem;
}

a {
    color: #017171;
    text-decoration-skip-ink: auto;
}

pre {
    font-size: 1.2rem;
    margin: 0;
    padding: 0;
}

code {
    padding: 2px 4px;
    background: #222f3e;
    color: #f3f3f3;
}

pre code {
    display: block;
    position: relative;
    overflow-x: auto;
    tab-size: 4;
    padding: 2rem;
    -webkit-overflow-scrolling: touch;
}

[role="status"] {
    font-size: 0.8rem;
    font-style: italic;
    padding: 0.5rem 0 0 0;
}

[role="status"]:empty {
    display: none;
}

[aria-hidden="true"] {
    font-style: normal;
}
            
          
!
            
              console.clear();

const buttonElement = document.querySelector('button');
const codeElement = document.querySelector('pre code');
const statusElement = document.querySelector('[role="status"]');

var clipboardStatus = 'unsupported';

if(navigator.clipboard) {
    buttonElement.innerText = 'Click to copy code to your clipboard';
    clipboardStatus = 'supported';
}

buttonElement.addEventListener('click', evt => {
    
    if(clipboardStatus !== 'supported') return;
    
    evt.preventDefault();
    
    navigator.clipboard.writeText(codeElement.innerText)
        .then(() => {
            statusElement.innerHTML = '<span aria-hidden="true">🎉</span> Code copied to clipboard!';
        })
        .catch(() => {
            statusElement.innerHTML = '<span aria-hidden="true">🛑</span> There was an error copying the code. Try again!';
        });
});
            
          
!
999px
Loading ..................

Console