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.


<div class="post right-align">

<p>"Now up comes Ted without any legs<br/>
And in their place there were two wooden pegs<br/>
She kissed him a dozen times or two<br/>
Saying “Holy moly could it be you?"</p>

<div class="post2">

<p>“Now was you drunk or was you blind<br/>
When you left your two fine legs behind?<br/>
Or was it out walking upon the sea<br/>
That tore your legs from the knees away?”</p>


  <p>Based on the article and comments in: <br /><a href="">Getting the hang of hanging punctuation</a></p>
 * hanging punctuation

	font: 1.5em/1.5 Helvetica Neue, Georgia, serif;
	padding: 4em;

	border-left: 1px solid red;
	border-right: 1px solid red;

	position: relative;
	margin: 1.5em 0;

	position: absolute;
	right: 100%;

.right-align {

.right-align .hanging-end { 

.right-align .hanging-start { 

.justify p {
  text-align-last: justify; 

	font-size: 0.75em;
 * Hanging Punctuation
 * This function takes a DOM element,
 * searches each of its direct descendants,
 * and, if the element begins with hangable punctuation,
 * the appropriate HTML class is applied to the element.
 * Then the parent DOM element get's a class to activate
 * the child classes we applied. 
function hangPunctuation(container) {
    // Punctuation marks that qualify to be hung
    var marks = [
        '\u201c',     // “ - ldquo - left smart double quote
        '\u201d',     // ” - rdquo - right smart double quote
        '\u2018',      // ‘ - lsquo - left smart single quote
        '\u0022',     // " - ldquo - left dumb double quote
        '\u0027',      // ' - lsquo - left dumb single quote
        '\u00AB',      // « - laquo - left double angle quote
        '\u2039',     // ‹ - lsaquo - left single angle quote
        '\u201E',     // „ - bdquo - left smart double low quote
        '\u201A'    // ‚ - sbquo - left smart single low quote
    // Loop over all direct descendants of the container
    // If it's a blockquote, loop over its direct descendants
    for(i=0; i<container.children.length; i++) {
        var el = container.children[i];
        if (el.tagName === 'BLOCKQUOTE') {
            for (var k = 0; k < el.children.length; k++) {
        else {
    // Check to see if the passed-in element 
    // begins or ends with one of the qualifying punctuation types
    // If it does, apply the appropriate class depending on the tag type
    function hangIfEligible(el) {
        var text = el.innerText || el.textContent;
        for(var i = 0; i < marks.length; i++) {
            // check if first char matches a hanging mark
            if ( text.indexOf(marks[i]) === 0 ) {
                el.innerHTML = '<span class="hanging-start">'+marks[i]+'</span>'+el.innerHTML.substr(1);
            // check if last char matches a hanging mark
            if (text.substr(text.length-1).indexOf(marks[i]) === 0) {
                el.innerHTML = 
                  el.innerHTML.substr(0, el.innerHTML.length-1);
                el.innerHTML += '<span class="hanging-end">'+marks[i]+'</span>';
window.onload = function() {
    var container = document.querySelector('.post')
    hangPunctuation( container );
    container = document.querySelector('.post2')
    hangPunctuation( container ); 
🕑 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.