Pen Settings

HTML

CSS

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

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

              
                <form onsubmit="e => preventDefault()">
  <div class="form-group">
    <label for="email" class="form-group__label">
      <span data-splitting="" aria-hidden="true" class="words chars splitting" style="--word-total:1; --char-total:5;"><span class="word" data-word="Email" style="--word-index:0;"><span class="char" data-char="E" style="--char-index:0;">E</span><span class="char" data-char="m" style="--char-index:1;">m</span><span class="char" data-char="a" style="--char-index:2;">a</span><span class="char" data-char="i" style="--char-index:3;">i</span><span class="char" data-char="l" style="--char-index:4;">l</span></span></span>
      <span class="sr-only">Email</span>
    </label>
    <input required type="email" id="email" class="form-input" title="Enter valid email address" placeholder="Enter valid email address" />
    <div class="form-group__error">Enter a valid email address</div>
  </div>
  <div class="form-group">
    <label for="password" class="form-group__label">
      <span data-splitting="" aria-hidden="true" class="words chars splitting" style="--word-total:1; --char-total:8;"><span class="word" data-word="Password" style="--word-index:0;"><span class="char" data-char="P" style="--char-index:0;">P</span><span class="char" data-char="a" style="--char-index:1;">a</span><span class="char" data-char="s" style="--char-index:2;">s</span><span class="char" data-char="s" style="--char-index:3;">s</span><span class="char" data-char="w" style="--char-index:4;">w</span><span class="char" data-char="o" style="--char-index:5;">o</span><span class="char" data-char="r" style="--char-index:6;">r</span><span class="char" data-char="d" style="--char-index:7;">d</span></span></span>
      <span class="sr-only">Password</span>
    </label>
    <input required="" type="password" id="password" class="form-input" placeholder="Password" title="Password must be at least 8 characters" pattern=".{8,}" />
    <div class="form-group__error">Password must be at least 8 characters</div>
  </div>
  <button type="submit">Submit</button>
</form>
              
            
!

CSS

              
                @import "https://unpkg.com/open-props/open-props.min.css";
@import "https://unpkg.com/open-props/normalize.min.css";

* {
  box-sizing: border-box;
}

:root {
  --red: hsl(18 100% 50%);
  --green: hsl(130 52% 46%);
  --yellow: hsl(44 83% 53%);
  --blue: hsl(215 100% 53%);
  --grey: hsl(0 0% 45%);
  --text: var(--gray-5);
  --transition: 0.2s;
  --valid: var(--green);
  --invalid: var(--red);
  --focus: var(--yellow);
  --blur: var(--gray-0);
  --disabled: var(--grey);
}

:where(html) {
  background-color: transparent;
  color-scheme: none;
}

body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow:  hidden;
  margin: 0;
  background-color: var(--gray-9);
  font-size: 1rem;
}

form {
  display: grid;
  grid-gap: 1rem;
}


.form-group {
  --color: var(--blur);
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: flex-end;
}

label {
  font-family: sans-serif;
  display: flex;
  font-weight: bold;
  padding-right: 1rem;
  transform-style: preserve-3d;
  transition: color var(--transition);
  color: var(--color);
  font-size: 1.25rem;
  grid-row: 1;
}
input {
  grid-row: 1;
  border: 4px solid var(--color);
  border-radius: 4px;
  padding: 1rem 2rem;
  font-weight: 400;
  transition: border-color var(--transition);
}

input:focus-visible {
  outline-color: var(--color);
}

input::placeholder {
  color: transparent;
}

button {
  padding: 1rem 2rem;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
  background: var(--disabled);
  font-weight: bold;
  font-size: 1.25rem;
  color: var(--gray-5);
  transition: color var(--transition), background var(--transition);
}

.form-group:has(:invalid) {
  --color: var(--invalid);
}

.form-group:has(:focus) {
  --color: var(--focus);
}

.form-group:has(:valid) {
  --color: var(--valid);
}

@media (prefers-reduced-motion: no-preference) {
  .form-group:has(:valid) label span {
    display: inline-block;
    animation: jump 0.25s calc(var(--char-index) * 0.05s);
  }
  @keyframes jump {
    50% {
      transform: translateY(-50%);
    }
  }
  .form-group:has(:invalid:not(:focus):not(:placeholder-shown)) {
    animation: shake 0.2s;
  }
  @keyframes shake {
    0%, 100% {
      transform: translateX(0);
    } 
    20%, 40%, 60%, 80% {
      transform: translateX(-2%);
    }
    10%, 30%, 50%, 70%, 90% {
      transform: translateX(2%);
    }
  }
}

.form-group:has(:placeholder-shown:not(:focus)) label span {
  animation: none;
}

.form-group:has(:placeholder-shown) {
  --color: var(--blur);
}

.form-group:has(:invalid:not(:focus):not(:placeholder-shown)) .form-group__error {
  display: block;
}

.form-group__input {
  position: relative;
}

.form-group__error {
  display: none;
  white-space: nowrap;
  color: var(--red);
  font-size: var(--font-size-0);
  grid-row: 2;
  grid-column: 2;
  padding: var(--size-2);
  text-align: center;
}


label span {
  display: inline-block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/*.form-group:has(:valid) ~ .form-group:has(:valid) ~ [type="submit"] {
  background: var(--valid);
  color: var(--gray-1);
}*/

form:valid [type="submit"] {
  background: var(--valid);
  color: var(--gray-1);
}
              
            
!

JS

              
                
              
            
!
999px

Console