Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

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


Auto Save

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.


                <!-- To learn more about this and follow a guided tutorial, head over to -->


                body {
    background: linear-gradient(45deg, #080404, #020606);
    height: 100%;
    color: #fff;
    text-align: center;
    font-family: monospace;
}h1 {
    font-size: 2.5em;
    font-weight: bold;
    color: #FF6347;
    text-shadow: 2px 2px 4px #000000;
    display: inline;

p {
    font-size: 1.2em;
    line-height: 1.6;
    color: #ddd;
    text-align: justify;
    margin: 0 auto;
    max-width: 800px;

button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    transition-duration: 0.4s;
    cursor: pointer;
    transition: all .2s;

button:hover {
    background-color: #473599;
    color: white;
    transform: scale(1.1) rotate3d(1, 1, 1, -10deg) translate(10px, 10px);
    border-radius: 10px;


                // Define a Controller class
class Controller {
	// Initialize the controller
	init = () => {
		// Initialize the view
		// Add a click event listener to the title that calls the editTitle method
			.addEventListener("click", (e) => app.view.editTitle(e));
	setTitle = (title) => {
		app.state.title = title;

// Define a View class
class View {
	// Constructor for the View class
	constructor(tag, innerHTML, parentElement) {
		// Create a new HTML element with the given tag
		this.element = document.createElement(tag);
		// Set the inner HTML of the element to the given HTML
		this.element.innerHTML = innerHTML;
		// Append the new element to the given parent element
	init = () => {
		// Create a new View instance
		new View(
            <h2>Welcome to the app.</h2>
	// Update the title in the view
	updateTitle = () =>
		(app.view.element.querySelector("h1").innerText = app.state.title);

	// Make the title editable when it's clicked
	editTitle = (e) => {
		const title =;
		title.contentEditable = true;

		// Set the title when Enter is pressed
		title.addEventListener("keypress", (e) => {
			if (e.key === "Enter") {
				title.contentEditable = false;

		// Set the title when it loses focus
		title.addEventListener("blur", () => {
			title.contentEditable = false;

// Define a Model class
class Model {
	// Constructor for the Model class
	constructor() {
		// Initialize the state with a title and count
		this.state = {
			title: "Hello World!",
			count: 0
		// Create a new View instance with a div element, no inner HTML, and append it to the body of the document
		this.view = new View("div", "", document.body);
		// Create a new Controller instance and pass the view instance to it
		this.controller = new Controller(this.view);
// Create a new instance of the Model class and assign it to the constant "app"
const app = new Model();
// Call the init method on the controller property of the app instance
// This initializes the view and adds event listeners to the HTML elements
document.onload = app.controller.init();