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 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

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

              
                
<div id="code">
  def get_encoding_from_headers(headers):
    """Returns encodings from given HTTP Header Dict.
    :param headers: dictionary to extract encoding from.
    :rtype: str
    """

    content_type = headers.get('content-type')

    if not content_type:
        return None

    content_type, params = _parse_content_type_header(content_type)

    if 'charset' in params:
        return params['charset'].strip("'\"")

    if 'text' in content_type:
        return 'ISO-8859-1'

    if 'application/json' in content_type:
        # Assume UTF-8 based on RFC 4627: https://www.ietf.org/rfc/rfc4627.txt since the charset was unset
        return 'utf-8'
</div>
              
            
!

CSS

              
                body {
  font-family: system-ui;
  background: #f06d06;
}

#code {
  white-space: pre; /* So the code won't wrap */
  width: 600px;
  height: 300px;
  margin-left: auto;
  margin-right: auto;
  overflow-x: auto;
  overflow-y: auto;
  visibility: hidden;
}

/* Hiding the scrollbars */

/* Chrome, Safari and Opera */
#code::-webkit-scrollbar {
    display: none;
}
#code {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Blinking cursor */
#code:after{
    content: "|";
    animation: blink 500ms linear infinite alternate;
}

@-webkit-keyframes blink{
    0%{opacity: 0;}
    100%{opacity: 1;}
}

@-moz-keyframes blink{
    0%{opacity: 0;}
    100%{opacity: 1;}
}

@keyframes blink{
    0%{opacity: 0;}
    100%{opacity: 1;}
}

              
            
!

JS

              
                var target = document.getElementById('code');

// Highlight the code
hljs.highlightElement(target);

// Get all the child nodes
var children = Object.values(document.getElementById('code').childNodes);

// Empty the target
target.innerText = '';

// And start the animation from the first node
type(0);

function type(i) {
    // Little helper
    function randomNumber(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
    }

    // Make the content visible
    if (i === 0) {
        target.style.visibility = 'visible';
    }

    // When we've displayed all the nodes
    // Just start over
    if (i >= children.length) {
        i = 0;
        target.innerText = '';
    }

    // Append each node to the target code placeholder
    // And scroll that div if the code scrolls past it
    if (children.hasOwnProperty(i)) {
        target.appendChild(children[i]);

        target.scrollTop = target.scrollHeight;
    }

    // Step to the next node
    i++;

    // Repeat the process
    // after a variable amount of time
    setTimeout(function () {
        type(i);
    }, randomNumber(200, 500));
}

// You made it this far, yay
// see it in action in my site
// https://genijaho.dev
              
            
!
999px

Console