cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.


		<meta charset="UTF-8">
		<title>Mad Libs</title>
		<link rel="stylesheet" href="css/style.css">
		<link href='https://fonts.googleapis.com/css?family=Fugaz+One' rel='stylesheet' type='text/css'>

		<meta charset="utf-8" />
		<title>Mad Libs</title>

		<h1>Mad Libs</h1>
<!--Create a div for the game-->
		<div id="forms"> 
<!--Give each input an id-->
				<input type="text" id="noun">
				<input type="text" id="adjective">
				<p>Verb (past-tense)</p>
				<input type="text" id="verb">
				<p>Someone's Name:</p>
				<input type="text" id="name">
				<p>Exclamation: </p>
				<input type="text" id="exclamation">

<!--Use a button to launch the function-->
		<button id="lib-button" onclick="madLibs()">lib it!</button>
		<div id="story"></div>


              * {
		font-family: Fugaz One;
		font-size: 22px;
		text-align: center;
		line-height: 5px;

h1 {
		text-align: center;
		font-family: Fugaz One;
		font-size: 72px;
		color: #FF3D96;

button {
		height: 50px;
		font-family: ;
		font-size: 22px;
		font-variant: small-caps;

#story {
		font-size: 24px;
		text-align: center;
		padding-top: 35px;
		font-family: Courier;
		line-height: 1;

input {
		font-family: Courier;
		border: 5px solid white;
		-webkit-box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1), 0 0 16px rgba(0, 0, 0, 0.1);
		-moz-box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1), 0 0 16px rgba(0, 0, 0, 0.1);
		box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1), 0 0 16px rgba(0, 0, 0, 0.1);
		padding: 15px;
		background: rgba(255, 255, 255, 0.5);
		margin: 0 0 10px 0;
              // This whole page works using just one function:
var madLibs = function() {
		// We will create a variable for each section of the page- the 5 inputs, and the empty <div> where the finished story will go. 
		var storyDiv = document.getElementById("story");
		var name = document.getElementById("name").value;
		var adjective = document.getElementById("adjective").value;
		var noun = document.getElementById("noun").value;
		var exclamation = document.getElementById("exclamation").value;
		var verb = document.getElementById("verb").value;
		// Once we create all of our variables, we change the HTML of our story <div> using innerHTML and adding a bunch of strings together, with punctuation and spaces. 
		storyDiv.innerHTML = name + " " + verb + " a " + adjective + " " + noun + ", " + exclamation + "!";

/*var libButton = document.getElementById('lib-button');
libButton.addEventListener('click', madLibs);*/
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................