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.


    <meta charset="utf-8">
        Demo auto complete
    <h2>Example form</h2>
<form method="post" id="usrForm">
<!--  Some values have display none here because if not present the client won't auto fill  -->
  <label style="display: none" for="address-level2">City</label>
  <input style="display: none" type="text" id="address-level2" name="city" autocomplete="shipping address-level2">
  <label for="state">State/Province</label>
  <input type="text" name="state" autocomplete="shipping address-level1" id="inputState" placeholder="State">
    <ul id="huge_list"></ul>
  <label style="display: none" for="country-name">Country Name</label>
  <input style="display: none" type="text" id="country-name" name="country-name" autocomplete="shipping country-name">
<input type="submit" value="Submit" name="submit">


                /*  Ignore this. It's super messy and just done quickly to make the form look nice */

ul, li {
  list-style: none;

ul {
  border: 1px solid #4285F4;
  border-radius: 5px;
  border-top: transparent;
  width: 100px;
  margin-top: -1px;
  background-color: white;
  position: absolute;
  z-index: 3;

li {
  width: fit-content;

li > p {
  margin-left: 15px;

.option {
  width: 140px;
  margin-left: -40px;
  height: 50px;
  text-align: left;
  justify-content: left;
  display: flex;

.option:hover {
  background-color: lightblue;

body {
  max-width: 25vw;
  margin: 25vh auto;
  font-family: Helvetica Neue,Helvetica,Arial,sans-serif; 

input {
  margin-top: 10px;
  padding: 2.5px;
  border-radius: 5px;
  border: 2px solid #4285F4;
  position: relative;
  z-index: 2;

input[type=submit] {
  background-color: #4285F4;
  color: white;
  position: absolute;
  top: 500px;
  z-index: 1


                /* Naive auto complete implementation based on
* & 

window.addEventListener("load", function(){
    // Add a keyup event listener to our input element
    var name_input =    document.getElementById('inputState');
    name_input.addEventListener("keyup", function(event){
      return hinter(event); 

// Autocomplete for form
function hinter(event, name_input) {
  // retireve the input element
  var input =;
  // retrieve the datalist element
  var huge_list = document.getElementById('huge_list');

  // minimum number of characters before we start to generate suggestions
  var min_characters = 1;

  if (input.value.length < min_characters ) { 
    huge_list.innerHTML = "";
  } else { 
    // clear any previously loaded options in the datalist
    huge_list.innerHTML = "";

    Object.keys(citiesObject).forEach(function(item) {
      // Create a new <option> element.
      if (!item.includes(input.value)) { return; };
      var option = document.createElement('div');
      option.innerHTML = "<li><p>" + item + "</p></li>";
      // attach the option to the datalist element

const citiesObject = {
  "New York": [
    "New York",
    "New Rochelle",
    "Mount Vernon",
    "White Plains",
    "Niagara Falls",
    "Valley Stream"
  "California": [
    "Los Angeles",
    "San Diego",
    "San Jose",
    "San Francisco",
    "Long Beach",
    "Santa Ana",
    "Chula Vista",
    "San Bernardino",
    "Moreno Valley",
    "Huntington Beach",
    "Santa Clarita",
    "Garden Grove",
    "Rancho Cucamonga",
    "Santa Rosa",
    "Elk Grove",
    "Thousand Oaks",
    "Simi Valley",
    "Santa Clara",
    "El Monte",
    "Costa Mesa",
    "San Buenaventura (Ventura)",
    "West Covina",
    "Daly City",
    "Santa Maria",
    "El Cajon",
    "San Mateo",
    "Jurupa Valley",
    "South Gate",
    "Mission Viejo",
    "Santa Monica",
    "Santa Barbara",
    "Newport Beach",
    "San Leandro",
    "San Marcos",
    "Citrus Heights",
    "Buena Park",
    "Redwood City",
    "Lake Forest",
    "Mountain View",
    "Chino Hills",
    "Baldwin Park",
    "San Ramon",
    "Union City",
    "Apple Valley",
    "Redondo Beach",
    "Rancho Cordova",
    "Yorba Linda",
    "Palo Alto",
    "Walnut Creek",
    "South San Francisco",
    "Yuba City",
    "San Clemente",
    "Laguna Niguel",
    "Pico Rivera",
    "Santa Cruz",
    "La Habra",
    "Monterey Park",
    "National City",
    "Huntington Park",
    "San Rafael",
    "La Mesa",
    "Fountain Valley",
    "Diamond Bar",
    "Lake Elsinore",
    "Cathedral City",
    "Palm Desert",
    "West Sacramento",
    "Aliso Viejo",
    "La Mirada",
    "Rancho Santa Margarita",
    "Palm Springs",
    "San Luis Obispo",
    "San Jacinto",
    "El Centro",
    "Bell Gardens",
    "Rancho Palos Verdes",
    "San Bruno",
    "Rohnert Park",
    "La Puente",
    "San Gabriel",
    "Morgan Hill",
    "Culver City",
    "La Quinta",
    "Los Banos",
  "Illinois": [
    "Arlington Heights",
    "Des Plaines",
    "Orland Park",
    "Tinley Park",
    "Oak Lawn",
    "Mount Prospect",
    "Hoffman Estates",
    "Oak Park",
    "Downers Grove",
    "Buffalo Grove",
    "Crystal Lake",
    "Carol Stream",
    "Rock Island",
    "Hanover Park",
    "Park Ridge",
    "Calumet City"
  "Texas": [
    "San Antonio",
    "Fort Worth",
    "El Paso",
    "Corpus Christi",
    "Grand Prairie",
    "Round Rock",
    "Wichita Falls",
    "College Station",
    "San Angelo",
    "League City",
    "Sugar Land",
    "Missouri City",
    "Flower Mound",
    "North Richland Hills",
    "New Braunfels",
    "Cedar Park",
    "Port Arthur",
    "San Marcos",
    "Cedar Hill",
    "Texas City",
    "Haltom City",
    "The Colony",
  "Pennsylvania": [
    "State College",
  "Arizona": [
    "Lake Havasu City",
    "Casa Grande",
    "Sierra Vista",
    "Oro Valley",
    "Bullhead City",
    "Prescott Valley",
    "Apache Junction"
  "Florida": [
    "St. Petersburg",
    "Fort Lauderdale",
    "Port St. Lucie",
    "Cape Coral",
    "Pembroke Pines",
    "Coral Springs",
    "Miami Gardens",
    "Palm Bay",
    "Pompano Beach",
    "West Palm Beach",
    "Miami Beach",
    "Boca Raton",
    "Deerfield Beach",
    "Palm Coast",
    "Boynton Beach",
    "Fort Myers",
    "Delray Beach",
    "Daytona Beach",
    "North Miami",
    "North Port",
    "Port Orange",
    "Coconut Creek",
    "Palm Beach Gardens",
    "Pinellas Park",
    "Coral Gables",
    "Bonita Springs",
    "North Miami Beach",
    "Oakland Park",
    "Fort Pierce",
    "North Lauderdale",
    "Cutler Bay",
    "Altamonte Springs",
    "St. Cloud",
    "Ormond Beach",
    "Hallandale Beach",
    "Winter Garden",
  "Indiana": [
    "Fort Wayne",
    "South Bend",
    "Terre Haute",
  "Ohio": [
    "Cuyahoga Falls",
    "Cleveland Heights",
    "Huber Heights",
    "Grove City"
  "North Carolina": [
    "High Point",
    "Chapel Hill",
    "Rocky Mount",
  "Michigan": [
    "Grand Rapids",
    "Sterling Heights",
    "Ann Arbor",
    "Farmington Hills",
    "Rochester Hills",
    "St. Clair Shores",
    "Royal Oak",
    "Dearborn Heights",
    "Battle Creek",
    "East Lansing",
    "Lincoln Park",
  "Tennessee": [
    "Johnson City",
  "Massachusetts": [
    "New Bedford",
    "Fall River",
    "Weymouth Town",
    "Barnstable Town",
  "Washington": [
    "Federal Way",
    "Spokane Valley",
  "Colorado": [
    "Colorado Springs",
    "Fort Collins",
    "Grand Junction",
    "Castle Rock",
    "Commerce City",
  "District of Columbia": [
  "Maryland": [
  "Kentucky": [
    "Louisville/Jefferson County",
    "Bowling Green",
  "Oregon": [
    "Lake Oswego",
  "Oklahoma": [
    "Oklahoma City",
    "Broken Arrow",
    "Midwest City",
  "Wisconsin": [
    "Green Bay",
    "Eau Claire",
    "West Allis",
    "La Crosse",
    "Fond du Lac",
    "New Berlin",
  "Nevada": [
    "Las Vegas",
    "North Las Vegas",
    "Carson City"
  "New Mexico": [
    "Las Cruces",
    "Rio Rancho",
    "Santa Fe",
  "Missouri": [
    "Kansas City",
    "St. Louis",
    "Lee's Summit",
    "St. Joseph",
    "St. Charles",
    "St. Peters",
    "Blue Springs",
    "Jefferson City",
    "Cape Girardeau"
  "Virginia": [
    "Virginia Beach",
    "Newport News",
  "Georgia": [
    "Augusta-Richmond County",
    "Athens-Clarke County",
    "Sandy Springs",
    "Johns Creek",
    "Warner Robins",
  "Nebraska": [
    "Grand Island"
  "Minnesota": [
    "St. Paul",
    "Brooklyn Park",
    "St. Cloud",
    "Maple Grove",
    "Eden Prairie",
    "Coon Rapids",
    "Apple Valley",
    "St. Louis Park",
  "Kansas": [
    "Overland Park",
    "Kansas City",
  "Louisiana": [
    "New Orleans",
    "Baton Rouge",
    "Lake Charles",
    "Bossier City",
  "Hawaii": [
  "Alaska": [
  "New Jersey": [
    "Jersey City",
    "Union City",
    "East Orange",
    "New Brunswick",
    "Perth Amboy",
    "West New York",
    "Atlantic City"
  "Idaho": [
    "Boise City",
    "Idaho Falls",
    "Coeur d'Alene",
    "Twin Falls"
  "Alabama": [
  "Iowa": [
    "Des Moines",
    "Cedar Rapids",
    "Sioux City",
    "Iowa City",
    "Council Bluffs",
    "West Des Moines",
    "Cedar Falls"
  "Arkansas": [
    "Little Rock",
    "Fort Smith",
    "North Little Rock",
    "Pine Bluff",
  "Utah": [
    "Salt Lake City",
    "West Valley City",
    "West Jordan",
    "St. George",
    "South Jordan",
  "Rhode Island": [
    "East Providence",
  "Mississippi": [
  "South Dakota": [
    "Sioux Falls",
    "Rapid City"
  "Connecticut": [
    "New Haven",
    "New Britain",
    "West Haven",
  "South Carolina": [
    "North Charleston",
    "Mount Pleasant",
    "Rock Hill",
    "Goose Creek",
    "Hilton Head Island",
  "New Hampshire": [
  "North Dakota": [
    "Grand Forks",
  "Montana": [
    "Great Falls",
  "Delaware": [
  "Maine": [
  "Wyoming": [
  "West Virginia": [
  "Vermont": [