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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="full center">
	<button onclick="virConsole.reset()">Reset Log</button>
<div class="left">
	<div class="half center" draggable="true">This is a draggable element</div>
	<div class="miscWrapper full">
		<button class="quarter">Button</button>
		<input class="quarter" type="text" placeholder="I'm a text field!" />
		<input type="file" />
	<div class="full"><textarea class="full">I'm a TextArea element. Try selecting text inside to see the "select" event fire!</textarea></div>
	<form class="demoForm full" action="" method="get" onsubmit="return false">
		<div style="width:100%; text-align: center">I'm a demo form! Try submitting to see event!</div>
		<input type="number" placeholder="20" />
		<input type="range" />
		<div>Checkbox: <input type="checkbox" /></div>
		<div>Radio elems: <input type="radio" name="group" /><input type="radio" name="group" /></div>
		<div class="full center">
			<input type="reset" />
			<input type="submit" value="submit form!" style="background-color: greenyellow; padding: 10px; font-size: 1.2rem;" />
	<div class="videoWrapper full">
		<div class="full center">This is a video element! Try playing, changing volume, etc. to see events!</div>
		<video  class="full" controls src=""

<div class="right">
	<div class="console">
		<div class="row">Event Log:</div>
	<div class="evtCounter">
		<div class="count"><span class="countInt">0</span> events</div>
              .full {
	width: 100%;
	margin-bottom: 8px;
.half {
	width: 49%;
.quarter {
	width: 24%;
.center {
	text-align: center;
	margin-left: auto;
	margin-right: auto;
.left,.right {
	width: 45%;
	min-height: 300px;
	border: 1px dashed black;
	padding: 5px;
	margin-left: 1%;
	float: left;
.console {
	padding: 10px;
	background-color: black;
	color: greenyellow;
	font-family: monospace;
	border-radius: 8px;
	overflow-y: scroll;
	height: 300px;
	margin-bottom: 10px;
.demoForm,.videoWrapper {
	border: 3px double black;
	margin: 10px;
	padding: 10px;
.left > * {
	margin-top: 8px;
.left .full {
	width: 90%;
	margin-left: 4%;
.left .half, .left .quarter {
	border: 1px solid black;
	padding: 2px;
	margin-left: auto;
	margin-right: auto;
	/* display: inline-block; */
	/* margin-right: 4px; */
button {
	font-size: 1.2rem;
.right {
	position: relative;
.evtCounter {
	position: absolute;
	top: 10px;
	right: 30px;
	padding: 10px;
	background-color:rgba(255, 255, 255, 0.8);
	border-radius: 20px;
              window.virConsole = {
	evtCount : 0,
		document.querySelector(".countInt").innerText = this.evtCount.toString();
	getElem : function(){
		return document.querySelector(".console");
	reset : function(){
		this.getElem().innerHTML = "";
		this.logMsg("Event Log:");
		this.evtCount = 0;
	createRowElem : function(text){
		var row = document.createElement("div");
		row.innerText = text;
		return row;
	simplifyJsEventObj : function(evt){
		return {
			type : evt.type,
			srcElement : evt.srcElement.outerHTML,
			target :,
			bubbles : evt.bubbles
	autoScroll : function(){
		var console = this.getElem();
	logMsg: function(text){
	logEvent : function(evt){
		var evtText = JSON.stringify(this.simplifyJsEventObj(evt),null,4);
		var evtText = "Fired @" + (new Date()).getTime() + " || " +  "Event Type: " + evt.type.toString();

function monitorEvents(element,cb) {
	var log = typeof(cb) === "function" ? cb : function(e) { console.log(e);};
	var events = [];
	for(var i in element) {
		if(i.startsWith("on")) events.push(i.substr(2));
	events.forEach(function(eventName) { 
		element.addEventListener(eventName, log); 

window.distributeEvent = function(evt){
// Since video events don't bubble by default, capture separately
var mediaEventStrings = ["audioprocess", "canplay", "canplaythrough", "complete", "durationchange", "emptied", "ended", "loadeddata", "loadedmetadata", "pause", "play", "playing", "ratechange", "seeked", "seeking", "stalled", "suspend", "timeupdate", "volumechange", "waiting"];
// Add page load events
// Lazy css alternative - set equal height columns
var left = document.querySelector(".left");
var right = document.querySelector(".right");
var maxHeight = getComputedStyle(left).height > getComputedStyle(right).height ? getComputedStyle(left).height : getComputedStyle(right).height; = maxHeight; = maxHeight;
virConsole.getElem().style.height = maxHeight;
🕑 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.