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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <form id="add-todos">
	<label for="new-todo">What do you want to do?</label>
	<input type="text" name="new-todo" id="new-todo">
	<button>Add Todo</button>

<div id="todos"></div>


                .todo {
	background: transparent;
	border: 0;
	color: inherit;
	font-size: 1em;
	margin: 0;
	padding: 0;

.todo.completed {
	text-decoration: line-through;


                // Get the #new-todo field
var todo = document.querySelector('#new-todo');

// Get the #todos container
var items = document.querySelector('#todos');

var state = {
	todos: [
			item: 'Buy a new wand',
			completed: false
			item: 'Get money from Gringotts',
			completed: true

var template = function () {

	// If there are no todos, show a message
	if (state.todos.length < 1) {
		return 'You do not have any todo items yet. Create one using the form above.';

	// Create a list of todos
	return '<ul>' + (todo, index) {
		var completed = todo.completed ? 'completed' : '';
		var html =
			'<li>' +
				'<button class="todo ' + completed + '" data-todo="' + index + '">' +
					todo.item +
				'</button>' +
    return html;
	}).join('') + '</ul>';


document.addEventListener('submit', function (event) {

	// Only run when the submitted form is #add-todos
	if ( !== 'add-todos') return;

	// Prevent the form from submitting to the server

	// Add a new todo item
		item: todo.value,
		completed: false

	// Render the UI
	items.innerHTML = template();

	// Clear the field so the user can add another todo
	todo.value = '';


document.addEventListener('click', function (event) {

	// Only run on .todo buttons
	if (!'todo')) return;

	// Get the todo item index
	var index ='data-todo');

	// Update the item in the state
	var completed ='completed') ? false : true;
	state.todos[index].completed = completed;

	// Update the UI
	items.innerHTML = template();


items.innerHTML = template();