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

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.

HTML

              
                <h1>Sentence Forms (not Mad Libs)</h1>

<form method="get" novalidate onsubmit="fakeValidate();">

  <p>
    <em>All fields are required.</em>
  </p>
  
  <div role="region" tabindex="-1" id="Errors" hidden>
    <h2>Hey, can you fix this?</h2>
    <ul>
      <li id="errName" hidden>I’d like to think we’re on a <em>something</em> name basis.</li>
      <li id="errEmail" hidden>I can’t respond if you don’t leave your address!</li>
      <li id="errSubject" hidden>What did you want to talk to me about?</li>
      <li id="errMessage" hidden>A blank message is sending me mixed signals.</li>
    </ul>
  </div>
  
  <p>
    <label for="your-adjective" id="Lbl01_your-adjective">I just had to tell you how</label> <select name="your-adjective" id="your-adjective" aria-labelledby="Lbl01_your-adjective WordBlank Lbl02_your-adjective" aria-required="true">
      <option value="inspiring">inspiring</option>
      <option value="funny">funny</option>
      <option value="foul-mouthed">foul-mouthed</option>
      <option value="weird">weird</option>
      <option value="spiffy">spiffy</option>
      <option value="right">right</option>
    </select> <span id="Lbl02_your-adjective">you are</span>. <label for="your-name">My name is</label> <input type="text" name="your-name" id="your-name" value="" size="10" aria-required="true" placeholder="name" autocomplete="name" onblur="populateOutput();"> and you can get in touch with me at <label for="your-email">my email address</label>: <input type="email" name="your-email" id="your-email" size="20" aria-required="true" placeholder="your email" autocomplete="email">. <label for="your-subject">I’m dying to talk to you about</label> <input type="text" name="your-subject" id="your-subject" size="30" placeholder="subject" aria-required="true">. <label for="your-message">Here’s what I’m thinking</label>:
  </p>

  <p>
    <textarea name="your-message" id="your-message" cols="50" rows="5" aria-required="true" placeholder="your message"></textarea>
  </p>

  <p>
    <select name="your-signoff" id="your-signoff" aria-labelledby="WordSignoff" aria-required="true">
      <option value="Sincerely">Sincerely</option>
      <option value="Thanks">Thanks</option>
      <option value="Love">Love</option>
      <option value="Coldly">Coldly</option>
    </select>
    ,<br>
    <output id="NameEcho"></output>
  </p>
  
  <p>
    <input type="submit" value="Ship it!">
  </p>

  <span hidden id="WordBlank">blank</span>
  <span hidden id="WordSignoff">Your signoff</span>
</form>

<p>
  This form has been adapted and made WCAG compliant (Levels A and AA). Used in my post <cite><a href="https://adrianroselli.com/2021/08/sentence-forms-not-mad-libs.html" target="_new">Sentence Forms (not Mad Libs)</a></cite>.
</p>
              
            
!

CSS

              
                body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.8;
  background: #fefefe;
  color: #333;
}

textarea,
input,
select {
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  max-width: 100%;
  border: .075em solid #333;
}

input,
select {
  line-height: 1;
}

textarea {
  width: 100%;
  line-height: 1.3;
}

input[type="submit"] {
/*   background-color: #333;
  color: #eee; */
  font-weight: bold;
  padding: 1em 2em;
}

input::placeholder, textarea::placeholder {
  color: #6161FF;
  opacity: 1;
}

textarea:focus,
input:focus,
select:focus {
  outline: 0.15em solid #00f;
  box-shadow: 0 0 0.2em #00f;
}

textarea[aria-invalid="true"],
input[aria-invalid] {
  background: linear-gradient(135deg, rgba(255,0,0,1) 0, rgba(255,0,0,1) .4em, rgba(255,255,255,1) .4em);
}

label {
  font-weight: bold;
}

form, form + p {
  margin: 1em auto;
  padding: 1em 2em;
  max-width: 40em;
}

form {
  background-color: #fefeee;
  border-radius: 1em;
  border: 1px solid #dcdccc;
  box-shadow: .2em .2em 1em #cccc;
}

#Errors {
  color: #c00;
  border: .01em dotted #c00;
  padding: 0 1em;
}

@media screen and (prefers-reduced-motion: no-preference) {
  #Errors:focus	{
    outline-width: 0;
    animation: Target 1s ease-out 1;
  }
}

#Errors:focus {
  outline: .1em solid #c00;
}

#Errors h2 {
  margin-top: .5rem;
}

h1 {
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  white-space: nowrap;
}

@keyframes Target {	
  from { outline-offset: -.25em; outline-color: #c00; outline-width: .1em; }
  to { outline-offset: 2em; outline-color: transparent; outline-width: 1em; }
}
              
            
!

JS

              
                function populateOutput() {
  var yourName = document.getElementById("your-name");
  var theOuput = document.getElementById("NameEcho");
  theOuput.innerText = yourName.value;
}

function fakeValidate() {
  var boxErrors = document.getElementById("Errors");
  var yourName = document.getElementById("your-name");
  var yourEmail = document.getElementById("your-email");
  var yourSubject = document.getElementById("your-subject");
  var yourMessage = document.getElementById("your-message");
  var errName = document.getElementById("errName");
  var errEmail = document.getElementById("errEmail");
  var errSubject = document.getElementById("errSubject");
  var errMessage = document.getElementById("errMessage");
  if (yourName.value == "") {
    errName.removeAttribute("hidden");
    yourName.setAttribute("aria-invalid","true");
    yourName.setAttribute("aria-describedby",errName.id);
    boxErrors.removeAttribute("hidden");
    boxErrors.focus();
    event.preventDefault();
  }
  if (yourEmail.value == "") {
    errEmail.removeAttribute("hidden");
    yourEmail.setAttribute("aria-invalid","true");
    yourEmail.setAttribute("aria-describedby",errEmail.id);
    boxErrors.removeAttribute("hidden");
    boxErrors.focus();
    event.preventDefault();
  }
  if (yourSubject.value == "") {
    errSubject.removeAttribute("hidden");
    yourSubject.setAttribute("aria-invalid","true");
    yourSubject.setAttribute("aria-describedby",errSubject.id);
    boxErrors.removeAttribute("hidden");
    boxErrors.focus();
    event.preventDefault();
  }
  if (yourMessage.value == "") {
    errMessage.removeAttribute("hidden");
    yourMessage.setAttribute("aria-invalid","true");
    yourMessage.setAttribute("aria-describedby",errMessage.id);
    boxErrors.removeAttribute("hidden");
    boxErrors.focus();
    event.preventDefault();
  }
}
              
            
!
999px

Console