HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<head>
<title>townie generator</title>
</head>
<body>
<h2>random townie generator</h2>
<div>
<button onClick="getTownie()">generate</button>
</div>
<div>
</br>
<div id="nameOutput"></div>
<div id="ageOutput"></div>
<div id="pronounsOutput"></div>
<div id="gpOutput"></div>
<div id="birthdayOutput"></div>
<div id="hobbyOutput"></div>
<div id="traitOutput"></div>
<div id="charmOutput"></div>
<div id="giftOutput"></div>
<div id="locationOutput"></div>
</body>
function getTownie(){
var name = ["Acacia", "Anise", "Apple", "Aspen", "Aurelia / Aurelis", "Autumn", "Avocado", "Basil", "Birch", "Bliss", "Blueberry", "Bluejay", "Botan", "Bubble", "Canary", "Carnation", "Carrot", "Chamomile", "Chanterelle", "Cherry", "Clementine", "Clover", "Coco", "Coffeebean", "Cosmos", "Daffodil", "Daisy", "Dandelion", "Doppio", "Elm", "Enoki", "Feather", "Fern", "Fig", "Flor", "Ginger", "Gourd", "Harmony", "Heather", "Hibiscus", "Holly", "Honey", "Huckleberry", "Iris", "Ivy", "Jasmine", "Java", "Junebug", "Juniper", "Kale", "Kuutti", "Laurel", "Daisy", "Lemon", "Lief", "Lily", "Lotus", "βLΓΊz", "Magnolia", "Maple", "Marguerite", "Marigold", "Matcha", "Mint / Minty", "Morel", "Mushroom", "Nala", "Oak", "Onion", "Orange", "Oyster", "Parsley", "Peach", "Peony", "Pepper", "Pine", "Plum", "Pomo", "Poppy", "Potato", "Pumpkin", "Raspberry", "Robin", "Rose", "Rowan", "Sage", "Spring", "Spruce", "Summer", "Sunny", "Sycamore", "Thistle", "Thyme", "Tomato", "Truffle", "Tulip", "Turnip", "Willow", "Winter", "Wisteria", "Aestral", "Aldebaran", "Amber", "Amethyst", "Andes", "Antares", "Argent", "Auburn", "Aura / Aurora", "Azul", "Bismuth", "Blanche", "Blaze", "Blondie", "Bolt", "Brooke", "Canyon", "Caster", "Cave", "Celeste", "Ciel", "Citrine", "Cliff", "Cloud", "Coral", "Craig", "Cressida", "Crystal", "Cyan", "Cygnus", "Diamond", "Ebony", "Emerald", "Etoile", "Everest", "Frost", "Gail", "Garnet", "Gold", "Gravel", "Hollow", "Hunter", "Iceberg", "Indigo", "Ivory", "Jasper", "Lapis / Lazuli", "Lava", "Leon", "Lilac", "Lionseye", "Luna / Lune", "Magnus", "Marina", "Misty", "Mojave", "Moonstone", "Mountain", "Neon", "Nimbus", "Noir", "Obsidian", "Ocean", "Opal", "Orion", "Paradox", "Pearl", "Pebble", "Peridot", "Phantom", "Pollux", "Pyrope", "Quarry", "Quartz", "Rain / Raine", "Redd", "Reef", "River", "Roja", "Ruby", "Rusty", "Saga", "Sapphire", "Scarlet", "Serenity", "Sierra", "Silver", "Skye", "Snow", "Sparky", "Squall", "Star", "Terra", "Topaz", "Tornado", "Verde", "Violet", "Wolke", "Yosemite", "Zircon", "Ace", "Affogato", "Amity", "Arcade", "Arrow", "Bean", "Bernie / Bennie", "Bingus", "Bite", "Blorbo", "Bolita", "Boo!", "Box", "Broom", "Bug", "Bunny", "Buster", "Buttercup", "Candelabra", "Candy", "Carafe", "Chase", "Clown", "Clown", "Cory", "Cream", "Cup", "Daydream", "Doily", "Donut", "Dove", "Dulce", "Duster", "Egg", "Felix", "Fork", "Frappe", "Glove", "Granola", "Greeble", "Honk", "Ianto", "Jewel", "Ketchup", "Kettle", "Kiki / Keke", "Kitty", "Knife", "Lamp", "Latte", "Lime", "Loaf", "Melody", "Milk", "Mixer", "Moss", "Muffin", "Mustard", "Noodle", "Nuggie", "Nurny", "Pancake", "Peanut", "Pippy", "Potoo", "Puppy", "Ramen", "Reese", "Retro", "Rogue", "Scrunchie", "Shark", "Shrimp", "Skelly", "Snail", "Sniff", "Sock", "Soup", "Spatula", "Spicy", "Splimbus", "Spoon", "Sprinkle", "Sugar", "Tadpole", "Tamago", "Teacup", "Toby", "Treasure", "Tummy", "Udon", "Valentine", "Waffle", "Wasabi", "Whisper", "Wilde", "Wish-Bone", "Worm", "Wrench", "Yogurt"];
var age = ["Baby", "Child", "Teenager", "Young Adult", "Adult", "Elder", "Ancient"];
var pronouns = ["They/Them", "She/Her", "He/Him", "She/They", "He/They", "It/Its", "Any"];
var gp = ["Feminine", "Masculine", "Androgynous", "Other"];
var bdayMonth = ["Spring", "Summer", "Fall", "Winter"];
var hobby = ["Animal training", "Ant keeping", "Archaeology/Fossil hunting", "Astronomy", "Baking/Cooking", "Baseball", "Beekeeping", "Beer brewing", "Biology", "Bird Watching", "Blacksmithing", "Board games", "Breakdancing", "Bug collecting", "Cheesemaking", "Chess", "Clothes Making", "Coin collecting", "Comic books", "Community Radio", "Cornhole", "Cosplaying", "Cross Stitch", "Crossword puzzles", "Cryptography", "Dance", "Drama (Acting)", "Drawing", "Engineering", "Fashion", "Filmmaking", "Fishing", "Football", "Freestyle rapping", "Gardening", "Genealogy", "Geology", "Ghost hunting", "Glass Blowing", "Gunsmithing", "Hiking", "Horticulture (Flowers)", "Houseplants", "Interior decorating", "Jigsaw puzzles", "Juggling", "Karaoke", "Knitting", "Lacrosse", "Leather crafting", "Martial arts (Judo, Karate, etc)", "Meditation", "Metal detecting/beach combing", "Model aircraft", "Model trains", "Music (Banjo)", "Music (Drums)", "Music (Guitar)", "Oil painting", "Origami", "People Watching", "Photography", "Ping-pong", "Poetry", "Pogs", "Pottery", "Pranks/Practical jokes", "Puppetry", "Reading (Fantasy)", "Reading (History)", "Reading (Mysteries)", "Reading (other)", "Rugby", "Running", "Scrapbooking", "Sculpting", "Singing", "Skiing", "Sledding", "Soap making", "Soccer", "Spellcrafting/Witchcraft", "Stamp collecting", "Stand Up comedy", "Sunbathing", "Surfing", "Swimming/Diving", "Tarot reading", "Thrifting", "Upcycling", "Vinyl records", "Volleyball", "Wine tasting", "Wood working", "Writing (Fiction)", "Writing (Journaling)", "Writing (Local history)", "Yo-yo", "Yoga", "Roll twice"];
var trait = ["Adorable", "Adventurous", "Agile", "Aloof", "Ambitious", "Anxious", "Arrogant", "Artistic", "Athletic", "Bitter", "Bold", "Book Smart", "Brooding", "Buff", "Careless", "Caring", "Cautious", "Charming", "Chatty", "Competitive", "Confident", "Crafty", "Creative", "Curious", "Daring", "Deceptive", "Determined", "Devoted", "Disabled", "Disarming", "Eccentric", "Elegant", "Excited", "Faithful", "Fashionable", "Foodie", "Frightened", "Frugal", "Generous", "Gentle", "Glamorous", "Grumpy", "Guilty", "Hard-working", "Healthy", "Hilarious", "Homebody", "Honest", "Hot-Headed", "Impulsive", "Independent", "Irritated", "Jolly", "Kind", "Lavish", "Lazy", "Loud", "Loyal", "Mischievous", "Mysterious", "Naive", "Needy", "Nerdy", "Nurturing", "Observant", "Optimistic", "Organized", "Outdoorsy", "Passionate", "Peppy", "Pessimistic", "Powerful", "Prepared", "Protective", "Quiet", "Rebellious", "Relaxed", "Romantic", "Scary", "Secretive", "Selfish", "Selfless", "Serious", "Sharp", "Shy", "Skeptic", "Sleepy", "Snarky", "Soft Spoken", "Sporty", "Street Smart", "Studios", "Superstitious", "Tenacious", "Timid", "Troubled", "Unruly", "Well-spoken", "Wild", "Wise"];
var charm = ["Always carrying a book", "Always carrying drink/food", "Always has pet with them", "Always in Uniform", "Always Smirking", "Animal Ears/Horns Accessory", "Apron", "Baby Face", "Bandages", "Bandana", "Barefoot", "Beauty Mark", "Belts", "Big Doll Eyes", "Big Hat", "Big Shoes", "Big Weapon/Tool", "Billowing Cloak", "Birthmark", "Bodysuit", "Boots", "Bracelet", "Brooch", "Burn Scar", "Cane", "Carries a Doll/Plush", "Choker", "Cleavage (Gender Neutral)", "Corset/Binder", "Crown", "Cute Lil Fang", "Dance Shoes", "Deadpan Expression", "Disheveled", "Dramatic Eyebrows", "Dressed for Success", "Earrings", "Eye(s) Covered", "Eyebags", "Eyepatch", "Face is obscured", "Face Paint", "Family Insignia", "Fanny Pack", "Flowers", "Freckles", "Frills/Ruffles", "Gap in front teeth", "Glasses", "Glitter", "Gloves", "Goggles", "Hair Antenna", "Headband", "Heterochromia", "High Collar", "Large Bag/Backpack", "Long Coat", "Long Eyelashes", "Makeup", "Mask", "Medal", "Midriff", "Mischievous Grin", "Missing Limb", "Mobility Device", "Monocle", "Muscular", "Narrow Frame", "Oversized Clothes", "Parasol/Umbrella", "Pendant", "Permanently Looks Grumpy", "Piercing(s)", "Pocketwatch", "Provocative Clothing", "Ribbon", "Ring", "Rosy Cheeks", "Scar(s)", "Scarf/Muffler", "Short", "Showing Some Skin", "Sunglasses", "Suspenders", "Tall", "Tattered Cloak", "Tattoo(s)", "Tie/Bow Tie", "Tight-fitting Clothes", "Tiny Bag", "Tiny Hat", "TOO MANY ACCESSORIES", "Toothpick/Lollipop", "Traditional Clothing", "Utility Belt", "Veil", "Wide Frame", "Wrinkles", "Zippers"];
var giftResource = ["π· Flowers", "π Mushrooms", "πΏ Herbs", "πΎ Grains", "π Fruit", "π₯ Vegetables", "π Berries", "π Fish", "π³ Wood", "π§± Ore", "π₯ Eggs", "π Gems", "π₯ Milk", "π§΅ Textiles/Wool", "π― Honey", "π Bugs", "𦴠Fossils", "π§ Spring Water", "π Rubbish", "π Ideas/Inspiration"];
var giftItem = ["π Clothes", "π Shoes", "π Medicine", "π Jewelry", "π Books", "β Tools", "πΌ Art", "πͺ Furniture", "π§Έ Toys", "πΊ Drinks", "π Food", "πͺ Fragrances", "π Floral Arrangements", "π§Ί Home Goods"];
var location = ["Abandoned House", "Abandoned workshop", "Alleyway", "An ancient shrine", "An underground bunker", "At the bottom of the well", "Bar at happy hour", "Bear cave", "Behind the waterfall", "Berry bush patch", "Boardwalk", "Bottom of the lake", "Burnt out tree that got hit by lightning", "Campgrounds", "Cave with glowing mushrooms", "Cave with old", "Cliff face", "Community Center", "Community Garden", "Coral reef", "Crystal cave", "Dense Forest", "Doctor's Office", "Fairy Circle", "Farm", "Field of wildflowers", "Field with crop circles", "Fishing pond", "Forest Clearing", "Fountain", "Gentle brook", "Giant tree in the middle of the forest", "Graveyard", "Harbor", "Haunted house", "Hidden from view", "Hiking trail", "Hill overlooking the town", "Hunting lodge", "In the middle of the ocean", "Inn", "Inside the old barn", "Library", "Local Shop", "Log cabin", "Market", "Metro station", "Monument to the founder of Iron Valley", "Museum", "Old carousel in the woods", "Old sunk ship", "Overgrown Farm", "Overgrown vehicle in the middle of an open field", "Park", "Patch of marshland", "Peaceful lake", "Playground", "Plaza", "Pond said to have healing properties", "Post Office", "Quarry", "Quiet dock at midnight", "Ranger station", "Red X on the side of a cavern wall", "Restaurant", "River rapids", "Roadside stand", "Rock cliffs overlooking the ocean", "Rock climbing spot", "Rolling hills of green grass", "Sandy beach", "School", "Secret mine entrance", "Secret treehouse", "Small island", "Snowy summit", "So deep in the forest you might as well be lost", "Stone circle where people gather at night", "The base of the mountain", "The bottom of the caves", "The fairgrounds", "The local temple", "The old iron mine", "The one house nobody goes in", "The road out of Iron Valley", "The top of the tallest tree", "\"The Witch's Hut\"", "Top of the mountain", "Town Hall", "Townie's House", "Townie's pool", "Tree grove", "Tree with a couple's name carved on it", "Tree with moss growing on the wrong side", "Under the bridge", "Underwater cave", "Valley of shimmering moonflowers", "Walking Trail", "Where the fog is so thick you can't see in front of you", "Wishing well"];
var nameNum = Math.floor(Math.random() * name.length);
var ageNum = Math.floor(Math.random() * age.length);
var pronounsNum = Math.floor(Math.random() * pronouns.length);
var gpNum = Math.floor(Math.random() * gp.length);
var bdMonthNum = Math.floor(Math.random() * bdayMonth.length);
var bdayNum = (Math.floor(Math.random() * 25) + 1);
var hobbyNum = Math.floor(Math.random() * hobby.length);
var traitNum = Math.floor(Math.random() * trait.length);
var traitNum2 = Math.floor(Math.random() * trait.length);
var giftResourceNum = Math.floor(Math.random() * giftResource.length);
var giftItemNum = Math.floor(Math.random() * giftItem.length);
var locationNum = Math.floor(Math.random() * location.length);
nameOutput.textContent = "Name: " + name[nameNum];
ageOutput.textContent = "Age: " + age[ageNum];
pronounsOutput.textContent = "Pronouns: " + pronouns[pronounsNum];
gpOutput.textContent = "Gender Presentation: " + gp[gpNum];
birthdayOutput.textContent = "Birthday: " + bdayMonth[bdMonthNum] + " " + bdayNum;
hobbyOutput.textContent = "Hobby: " + hobby[hobbyNum];
traitOutput.textContent = "Traits: " + trait[traitNum] + " & " + trait[traitNum2];
giftOutput.textContent = "Favorite Gifts: " + giftResource[giftResourceNum] + " & " + giftItem[giftItemNum];
locationOutput.textContent = "Special Location: " + location[locationNum];
}
Also see: Tab Triggers