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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

    .title {
    .publication-year {
        font-size:90%; padding-left:1em;
    .active-list-item {
        border:1px solid #000;
    .bio {
        padding:2% 5%;
        box-shadow: 5px 5px 5px #000;
        border:1px solid #ccc;
<h1>My Reading Journal</h1>
    <li data-isbn="9780679604136">
        <span class="author">Rebecca Stott</span>, <span class="title">
        Darwin’s Ghosts: The Secret History of Evolution</span> <span
    <li data-isbn="9780520258327">
        <span class="author">David W. Deamer</span>, <span class="title">
        First Life: Discovering the Connections Between Stars, Cells, and 
        How Life Began</span> <span class="publication-year">2011</span>
    <li data-isbn="9781118964781">
        <span class="author">Alister E. McGrath</span>, <span class="title"
        >Dawkins’ God: From The Selfish Gene to The God Delusion</span> 
        <span class="publication-year">2015</span>

    var books = {
        '9780679604136' : {
            'publisher' : 'Random House Publishing Group',
            'pages' : '432',
        '9780520258327' : {
            'publisher' : 'University of California Press',
            'pages' : '271',
        '9781118964781' : {
            'publisher' : 'John Wiley & Sons',
            'pages' : '208',
    var authors = {
        'Rebecca Stott' : {
            'born' : '1964',
            'degree' : 'PhD',
            'profession' : 'Professor at the University of East Anglia',
            'other-works' : ['Ghostwalk (2007)', 'The Coral Thief (2009)'],
        'David W. Deamer' : {
            'born' : '1939',
            'degree' : 'PhD',
            'profession' : 'Research professor at UCSC',
            'other-works' : ['Membrane Structure (2012)'],
        'Alister E. McGrath' : {
            'born' : '1953',
            'degree' : 'PhD',
            'profession' : 'Professor at Oxford University',
            'other-works' : ['Mere Theology (2010)', 'C. S. Lewis, A Life (2013)']
    var all_book_list_items = document.querySelectorAll('li');
    for(var i = 0; i < all_book_list_items.length; i++) {
        all_book_list_items[i].addEventListener('click', function() {
            if(this.querySelectorAll('.extras').length) {
                var the_extras_span = this.querySelectorAll('.extras')[0];
                this.className = '';
            this.className = 'active-list-item';
            var isbn = this.getAttribute('data-isbn');
            var book_object = books[isbn];
            this.innerHTML = this.innerHTML + '<span class="extras">' 
            + '<br> Publisher: ' + book_object.publisher
            + '. Page count: ' + book_object.pages + '</span>';
    document.body.addEventListener('click', function(event) {
        var clicked_element =;
        if (clicked_element.classList.contains("author")) {
            var author_name = clicked_element.innerHTML;
            var author_object = authors[author_name];
            var bio_div = document.createElement('div');
            bio_div.className = 'bio';
            bio_div.innerHTML = '<h2>' + author_name + ' (' 
                + + ')</h2>';
            bio_div.innerHTML += '<h3>' + author_object.profession + '</h3>';
            bio_div.innerHTML += '<div>Born: ' + author_object.born + '<br>';
            bio_div.innerHTML += 'Other works: ' 
                + author_object['other-works'].join(', ');
            bio_div.innerHTML += '</div>';
            bio_div.addEventListener('click', function() {

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.