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.


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.


                <p>Required fields are marked with an asterisk <abbr title="Required field">*</abbr></p>
<!-- We're using novalidate attribute here to avoid the built in browser validation -->
<form method="post" action="/" id="test-form" novalidate>
	<div id="form-message" class="form-message" role="alert" aria-atomic="true"></div>
	<div class="form-field">
		<label for="name">Name <abbr title="required">*</abbr></label>
		<input type="name" name="name" id="name" required />
	<div class="form-field">
		<label for="email">E-mail <abbr title="required">*</abbr></label>
		<input type="email" name="email" id="email" required />
	<button type="submit">Send</button>


                label {
	display: block;

.form-message {
	background-color: #ffffd4;

.form-field {
	margin: 1rem 0;

.field-error {
	color: maroon;


                /* This javascript is only made to make a quick
 * demonstration of the form states when validating.
 * The code itself is a quick hack and nothing that 
 * should be used in the real world (wide web).
 * I'm not proud of this...

const testForm = document.getElementById("test-form");
const formMessageHolder = document.getElementById("form-message");
const nameField = document.getElementById("name");
const emailField = document.getElementById("email");

testForm.addEventListener("submit", event => {
	const nameValue = nameField.value;
	const emailValue = emailField.value;
	const nameDescNode = document.getElementById("nameDesc");
	const emailDescNode = document.getElementById("emailDesc");

	// Cleanup inline error messages
	if (nameDescNode) {
	if (emailDescNode) {
	// Display error message if form is invalid
	if (nameValue === "" || emailValue === "") {
		formMessageHolder.innerHTML = `
			<p>Please review the form and fix the following errors:</p>
				${nameValue ? "" : "<li>The name field must be filled in.</li>"}
				${emailValue ? "" : "<li>The e-mail field must be filled in.</li>"}

		if (nameValue === "") {
			createErrorDescription("nameDesc", nameField, "The name field must be filled in.");

		if (emailValue === "") {
			createErrorDescription("emailDesc", emailField, "The e-mail field must be filled in.");

		// Set focus on the first invalid field
		nameValue === "" ? nameField.focus() : emailField.focus();
	} else {
		// Display success message if form was sent successfully
		formMessageHolder.innerHTML = "<p>The form was sent successfully!</p>";

// Helper method to create an field error message
const createErrorDescription = (name, field, message) => {
	var newNode = document.createElement("div");
	newNode.setAttribute("id", name);
	field.setAttribute("aria-describedby", name);
	newNode.innerHTML = message;