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.


                <form action="#" autocomplete="off">
  <h2>Empty Validation with pure CSS</h2>
  <p>Type something into this input field below.</p>
    <li>When input is filled: Borders turn green</li>
    <li>When validation fails: Borders turn red</li>
  <div class="input">
    <label for="input">Label </label>
    <input type="text" name="input" id="input" placeholder="Type something in here">



                html {
  font-size: 125%;
  line-height: 1.4;

body {
  display: grid; 
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(45deg, hsl(240, 50%, 78%), hsl(30, 100%, 50%))

/* Demo styles */
h2 {
  font-size: 2em;

h2, p {
  margin: 0; 

p + * {
  margin-top: 1em; 

h2 + p {
  margin-top: 1em;

/* Form styles */

form {
  max-width: 20em;
  border: 0.5em solid hsl(30, 76%, 10%);
  padding: 2em;
  background: white;

.input {
  display: flex; 
  align-items: center;

label {
  margin-right: 1ch;

input {
  width: 100%;
  font: inherit;
  padding: 0.25em 0.5em;
  border: 0.125em solid hsl(30, 76%, 10%); 
  outline: none;

/* Show green borders when valid */
input[data-state="valid"] {
  border-color: hsl(120, 76%, 50%);

/* Show red borders when filled, but invalid */
input[data-state="invalid"] {
  border-color: hsl(0, 76%, 50%);;



                const input = document.querySelector('input')

input.addEventListener('input', evt => {
  const value = input.value
  if (!value) {
    input.dataset.state = ''
  const trimmed = value.trim()
  if (trimmed) {
    input.dataset.state = 'valid'
  } else {
    input.dataset.state = 'invalid'