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

              
                <h1 title='Sure this name is trademarked!'>Typo</h1>
<pre id="output"></pre>
<p>
  <button>Restart</button>
</p>
              
            
!

CSS

              
                @import "compass/css3";

body{
  font-family: 'Montserrat', sans-serif;
  background:#2980b9;
}

h1{
  color:#fff;
  text-align:center;
}

pre{
	font-family: 'Source Code Pro', monospace;
  margin:2em;
  background:#222;
  color:#aaa;
  border:5px solid #666;
  padding:1em;
  height:300px;
  width:80%;
  max-width:800px;
  margin:2em auto;
}

p{
  text-align:center;
}

button{
  display:inline-block;
  display:none;
  background:#fff;
  border:none;
  border-radius:4px;
  padding:1em;
}
              
            
!

JS

              
                $(function(){
  // The base speed per character
	time_setting = 30;
  // How much to 'sway' (random * this-many-milliseconds)
	random_setting = 100;
  // The text to use NB use \n not real life line breaks!
	input_text = "<div class='main'>\n\t<!-- holy moly I forgot how fast I can type when I get going -->\n\t<h1>Introduction</h1>\n\t<p>Welcome to my website, all about my adventures with code</p>\n</div><!-- .main -->";
  // Where to fill up
	target_setting = $("#output");
  // Launch that function!
	type(input_text, target_setting, 0, time_setting, random_setting);

	$("button").click(function(){
    // When you click, remove the button
		$(this).fadeOut('fast', function(){
      // Remove all the text, then show the pre area again
			target_setting.text("").show();
      // And start again!
			type(input_text, target_setting, 0, time_setting, random_setting);
		});
	});
});

function type(input, target, current, time, random){
  // If the current count is larger than the length of the string, then for goodness sake, stop
	if(current > input.length){
    // Write Complete
		console.log("Complete.");
    // Wait a bit, then do the complete function
		setTimeout(function(){
			finished(input, target, current, time, random);
		},3000);
		
	}
	else{
		console.log(current)
    // Increment the marker
		current += 1;
    // fill the target with a substring, from the 0th character to the current one
		target.text(input.substring(0,current));
    // Wait ...
		setTimeout(function(){
      // do the function again, with the newly incremented marker
			type(input, target, current, time, random);
      // Time it the normal time, plus a random amount of sway
		},time + Math.random()*random);
	}
}

// when its finished
function finished(input, target, current, time, random){
  // fade out the pre
	target.slideUp('fast', function(){
    // fade in the button
		$("button").delay(100).fadeIn('slow');	
	});
}
              
            
!
999px

Console