Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <!--
Questions:
- what is so special about the FORM tag?
- is it still relevant nowadays?
-->
<form id="chat" method="post" action="/my-backend-script">
  <input type="text" placeholder="What's on your mind?" />
  <input type="submit" value="Post" />
</form>

              
            
!

CSS

              
                /*
Questions:
- what is "display: flex" and "flex: 1"?
- what is "input[type="text"]"?
*/

#chat {
  display: flex;
}

#chat input[type="text"],
#chat input[type="submit"] {
  padding: 5px 10px;
  border: 1px solid #666;
  outline: none;
}

#chat input[type="text"] {
  flex: 1;
  margin-right: 10px;
}

#chat input[type="text"]:focus {
  border-color: #369;
}

#chat input[type="submit"] {
  margin-right: 10px;
  text-transform: uppercase;
}

#chat input[type="submit"]:active {
  border-color: #369;
  background-color: #369;
  color: #fff;
}


              
            
!

JS

              
                /*
Questions:
- what happens if you remove the event listener, run the exercise, then click "POST"?
- what does "preventDefault()" do?
- what does "stopPropagation()" do?
*/
const onFormSubmit = (event) => {
  event.preventDefault()
  event.stopPropagation()

  alert('do stuff...')
}

document
  .getElementById('chat')
  .addEventListener('submit', onFormSubmit)

              
            
!
999px

Console