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.


                <div class="container">
	<h1 class="page-header">Native HTML5 Drag and Drop <small>Full Demo</small></h1>
	<div id="columns-full" class="columns clearfix">
		<div class="column" draggable="true"><header>A</header><div class="count" data-col-moves="0"></div></div>
		<div class="column" draggable="true"><header>B</header><div class="count" data-col-moves="0"></div></div>
		<div class="column" draggable="true"><header>C</header><div class="count" data-col-moves="0"></div></div>
		<div class="column" draggable="true"><header>D</header><div class="count" data-col-moves="0"></div></div>
	<small>Taken and updated (with the classList API) from <a href="">HTML5Rocks</a><br>
		No IE support as it does not support the DataTransfer API.</small>



                .column {
	background-color: #ccc;
	border-radius: 10px;
	border: 2px solid #666666;
	box-shadow: inset 0 0 3px #000;
	cursor: move;
	float: left;
	height: 150px;
	margin-bottom: 30px;
	margin-right: 5px;
	text-align: center;
	width: 150px;

.column header {
	background: linear-gradient(to right, rgb(0,0,0), rgb(79,79,79), rgb(21,21,21));
	border-bottom: 1px solid #ddd;
	border-top-left-radius: 10px;
	border-top-right-radius: 10px;
	box-shadow: 5px;
	color: #fff;
	padding: 5px;
	text-shadow: #000 0 1px;

.column {
	transition: transform 0.2s ease-out;

.column.over {
	border: 2px dashed #000;

.column.moving {
	opacity: 0.25;
	transform: scale(0.8);

.column .count {
	font-weight: bold;
	padding-top: 15px;
	text-shadow: #fff 0 1px;


                // Full example
(function() {
	var id_ = 'columns-full';
	var cols_ = document.querySelectorAll('#' + id_ + ' .column');
	var dragSrcEl_ = null;

	this.handleDragStart = function(e) {
		e.dataTransfer.effectAllowed = 'move';
		e.dataTransfer.setData('text/html', this.innerHTML);

		dragSrcEl_ = this;

		// this/ is the source node.

	this.handleDragOver = function(e) {
		if (e.preventDefault) {
			e.preventDefault(); // Allows us to drop.

		e.dataTransfer.dropEffect = 'move';

		return false;

	this.handleDragEnter = function(e) {

	this.handleDragLeave = function(e) {
		// this/ is previous target element.

	this.handleDrop = function(e) {
		// this/ is current target element.

		if (e.stopPropagation) {
			e.stopPropagation(); // stops the browser from redirecting.

		// Don't do anything if we're dropping on the same column we're dragging.
		if (dragSrcEl_ != this) {
			dragSrcEl_.innerHTML = this.innerHTML;
			this.innerHTML = e.dataTransfer.getData('text/html');

			// Set number of times the column has been moved.
			var count = this.querySelector('.count');
			var newCount = parseInt(count.getAttribute('data-col-moves')) + 1;
			count.setAttribute('data-col-moves', newCount);
			count.textContent = 'moves: ' + newCount;

		return false;

	this.handleDragEnd = function(e) {
		// this/ is the source node.
		[], function(col) {

	[], function(col) {
		col.setAttribute('draggable', 'true'); // Enable columns to be draggable.
		col.addEventListener('dragstart', this.handleDragStart, false);
		col.addEventListener('dragenter', this.handleDragEnter, false);
		col.addEventListener('dragover', this.handleDragOver, false);
		col.addEventListener('dragleave', this.handleDragLeave, false);
		col.addEventListener('drop', this.handleDrop, false);
		col.addEventListener('dragend', this.handleDragEnd, false);