Pen Settings



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


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.


                <div class="formWrap">
	<form id="localStorageTest" method="post" action="">
	    <label>Question 1</label><br>
	    <input type="text" name="q0" id="q0" class="q" value="" /><br>
	    <label>Question 2</label><br>
	    <input type="text" name="q1" id="q1" class="q" value="" /><br>
		<button type="button" id="store">Store Items</button>
		<button type="button" id="retrieve">Get Items</button>
    <button type="button" id="clear">Clear Items</button>


                $primary: #222;
$primary-light: lighten($primary, 25%);
$primary-light-x: lighten($primary, 30%);
$primary-light-xx: lighten($primary, 50%);
* { box-sizing: border-box; }
html {
  font-family: helvetica;
  font-size: 16px;
body {
  background-color: $primary;
.formWrap {
  width: 29em;
  margin: 2em auto;
label {
  display: block;
  padding: 1em 0 0 0;
  color: $primary-light;
input {
  font-size: 2em;
  width: 100%;
  padding: .5em;
  border-radius: .25em;
  border: 1px solid $primary-light;
  background-color: #f2f2f2;
button {
  border: 0;
  background-color: orange;
  padding: 1rem 0;
  width: 32.666%;
  font-size: 1.5rem;
  color: #fff;
  margin: 2rem 0;
  border-radius: .25em;
  border: 1px solid  $primary-light-x;
  &:first-of-type { margin-left: 0; }
  &:hover { background-color: $primary-light-x; }
  &:active { 
    box-shadow: inset 0 0 10px $primary-light-xx;
    background-color: $primary-light-x; }
  &:focus { outline: 0; }


                var stbt = document.getElementById("store");
stbt.addEventListener("click", storeIt, false);

var rtbt = document.getElementById("retrieve");
rtbt.addEventListener("click", retrieve, false);

var clbt = document.getElementById("clear");
clbt.addEventListener("click", clear, true);

var elv = document.getElementsByClassName('q');

function storeIt() {
  for (var i = 0; i < elv.length; i++) {
    var theVal = elv[i].value;
    if(theVal == '') { 
      alert("Enter content, or you will save empty stings."); 
      return false; 
    var storeName = elv[i].className + [i];
    localStorage.setItem(storeName, theVal);
  alert("You've stored items. Refresh and click 'Get Items' to re-populate the fields.");

function retrieve() {
  if (!window.localStorage.length) { alert("Nothing stored!"); }
  for (var i = 0; i < localStorage.length; i++){
   // var obj = localStorage.getItem(localStorage.key(i));
    document.getElementById('q'+[i]).value = localStorage.getItem('q'+[i]);
function clear() {
  if(!window.localStorage.length) {
    alert("Local storage is empty.");
  var vlu = document.getElementsByClassName('q');
  for (var i = 0; i < vlu.length; i++){
    vlu[i].value = '';