Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <!-- See also: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML_sections_and_outlines -->

<div class="panel">
    <div id="test" class="test">
        <p>"Table of Contents" bookmarklet*</p>

        <p>Bookmark this: <a class="button" href="javascript:(function(){var e=document.querySelectorAll('h1,h2,h3,h4,h5,h6');if(e.length){var t=document.createElement('div');t.style='background-color:white;border:1px solid black;color:black;display:inline-block;font-size:16px;left:0;line-height:1.5;max-height:calc(100% - 1em);margin:0.5em;max-width:calc(100% - 1em);overflow-y:scroll;padding:0.5em 1.6em 0.5em 1em;position:fixed;top:0;z-index:9999;';var n=document.createElement('button');n.style='background-color:#eee;border:none;cursor:pointer;font-weight:700;line-height:1.8;padding:0 0.6em;position:absolute;right:0;top:0;',n.type='button',n.textContent='x',n.onclick=function(e){this.parentNode.remove()},t.appendChild(n);var i=document.createElement('ol');i.style='list-style-position:inside;list-style-type:disc;margin:0;padding:0;';for(var o=0,l=e.length;l>o;o++){var r=e[o],a=parseInt(r.tagName.substring(1,2)),d='&ndash;'.repeat(a),c=r.tagName+': '+r.textContent,p=document.createElement('li');if(p.innerHTML=d,r.id){var m=document.createElement('a');m.style='color:#0043eb;text-decoration:underline;',m.innerHTML=c,m.href='#'+r.id,p.appendChild(m)}else p.innerHTML=p.innerHTML.concat(c);i.appendChild(p)}t.appendChild(i),document.body.appendChild(t);}})();">ToC</a></p>
        
        <p><small>* Tested only in the latest stable version of Google Chrome for Mac on July 11 2016 (Version 51.0.2704.103 (64-bit)).</small></p>
    </div>
</div>
<div class="panel">
    <h1 id="header-1">Ornare Ultricies Condimentum Magna</h1>
    <h2 id="header-2">Sollicitudin Vehicula Fringilla Vestibulum</h2>
    <h3 id="header-3">Ligula Ornare Cursus</h3>
    <h2 id="">Elit Tellus Nullam Ornare Fusce</h2>
    <h3>Sit Quam Ultricies</h3>
    <h2>Ridiculus Fringilla Pharetra Magna</h2>
    <h3>Vestibulum Fusce Pharetra Ullamcorper Nullam</h3>
    <h5 id="header-5">Vehicula Tellus</h5>
    <h6 id="header-6">Aenean Fermentum Egestas Bibendum</h6>
    <h4>Venenatis Ipsum Cras Aenean</h4>
    <h2>Porta Fusce Etiam Ipsum</h2>
    <h3>Risus Dapibus Parturient Mattis Malesuada</h3>
    <h4 id="header-4">Tristique Consectetur Aenean</h4>
    <h3>Tortor Ornare Vulputate Adipiscing</h3>
    <h3>Aenean Fusce Venenatis Quam</h3>
    <h2>Aenean Porta Vestibulum Vehicula Mollis</h2>
    <h2>Cursus Ornare Sem</h2>
</div>
              
            
!

CSS

              
                body {
    font: 1em/1.45 sans-serif;
}

.panel {
    float: left;
    padding: 0.3em 0.6em;
    width: 40%;
}

.button {
    background-color: blue;
    border-radius: 0.2em;
    color: white;
    padding: 0.3em 0.6em;
}
              
            
!

JS

              
                if (false) {
    javascript:(function(){
        var headers = document.querySelectorAll('h1,h2,h3,h4,h5,h6');
        if (headers.length) {
            var container = document.createElement('div');
            container.style = 'background-color:white;border:1px solid black;color:black;display:inline-block;font-size:16px;left:0;line-height:1.5;max-height:calc(100% - 1em);margin:0.5em;max-width:calc(100% - 1em);overflow-y:scroll;padding:0.5em 1.6em 0.5em 1em;position:fixed;top:0;z-index:9999;';

            var closeButton = document.createElement('button');
            closeButton.style = 'background-color:#eee;border:none;cursor:pointer;font-weight:700;line-height:1.8;padding:0 0.6em;position:absolute;right:0;top:0;';
            closeButton.type = 'button';
            closeButton.textContent = 'x';
            closeButton.onclick = function(event) {
                this.parentNode.remove();
            };
            container.appendChild(closeButton);

            var list = document.createElement('ol');
            list.style = 'list-style-position:inside;list-style-type:disc;margin:0;padding:0;';
            for (var i = 0, length = headers.length; i < length; i++) {
                var header = headers[i];
                var headersLevel = parseInt(header.tagName.substring(1, 2));
                var levelText = '&ndash;'.repeat(headersLevel);
                var headerText = header.tagName + ': ' + header.textContent;

                var listItem = document.createElement('li');
                listItem.innerHTML = levelText;
                if (header.id) {
                    var headerLink = document.createElement('a');
                    headerLink.style = 'color:#0043eb;text-decoration:underline;';
                    headerLink.innerHTML = headerText;
                    headerLink.href = '#' + header.id;
                    listItem.appendChild(headerLink);
                } else {
                    listItem.innerHTML = listItem.innerHTML.concat(headerText);
                }
                list.appendChild(listItem);
            }
            container.appendChild(list);
            document.body.appendChild(container);
        }
    })();
}
              
            
!
999px

Console