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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

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.


                h1 Drag and Drop HTML5

  .drag-item(draggable="true") A
  .drag-item(draggable="true") B
  .drag-item(draggable="true") C
  .drag-item(draggable="true") D
  .drag-item(draggable="true") E
  .drag-item(draggable="true") F
  .drag-item(draggable="true") G
  .drag-item(draggable="true") H
  .drag-item(draggable="true") I
  .drag-item(draggable="true") J
  .drag-item(draggable="true") K
  .drag-item(draggable="true") L


                @import "nib"

  user-select none

  overflow hidden
  margin 10px auto
  width 500px
  border 1px solid #ccc

  float left
  padding 50px 20px
  width 25%
  text-align center
  color #555
  background #ddd
  border 1px solid #ccc
  box-sizing border-box
  transition 0.25s

  opacity 0.8

  opacity 0.5
  transform scale(0.9)


                function DragNSort (config) {
  this.$activeItem = null;
  this.$container = config.container;
	this.$items = this.$container.querySelectorAll('.' + config.itemClass);
  this.dragStartClass = config.dragStartClass;
  this.dragEnterClass = config.dragEnterClass;

DragNSort.prototype.removeClasses = function () {
	[]$items, function ($item) {
		$item.classList.remove(this.dragStartClass, this.dragEnterClass);

DragNSort.prototype.on = function (elements, eventType, handler) {
	[], function (element) {
    element.addEventListener(eventType, handler.bind(element, this), false);

DragNSort.prototype.onDragStart = function (_this, event) {
  _this.$activeItem = this;

  event.dataTransfer.effectAllowed = 'move';
  event.dataTransfer.setData('text/html', this.innerHTML);

DragNSort.prototype.onDragEnd = function (_this) {

DragNSort.prototype.onDragEnter = function (_this) {

DragNSort.prototype.onDragLeave = function (_this) {

DragNSort.prototype.onDragOver = function (_this, event) {
  if (event.preventDefault) {

  event.dataTransfer.dropEffect = 'move';

  return false;

DragNSort.prototype.onDrop = function (_this, event) {
	if (event.stopPropagation) {

  if (_this.$activeItem !== this) {
    _this.$activeItem.innerHTML = this.innerHTML;
    this.innerHTML = event.dataTransfer.getData('text/html');


  return false;

DragNSort.prototype.bind = function () {
	this.on(this.$items, 'dragstart', this.onDragStart);
	this.on(this.$items, 'dragend', this.onDragEnd);
	this.on(this.$items, 'dragover', this.onDragOver);
	this.on(this.$items, 'dragenter', this.onDragEnter);
	this.on(this.$items, 'dragleave', this.onDragLeave);
	this.on(this.$items, 'drop', this.onDrop);

DragNSort.prototype.init = function () {

// Instantiate
var draggable = new DragNSort({
	container: document.querySelector('.drag-list'),
  itemClass: 'drag-item',
  dragStartClass: 'drag-start',
  dragEnterClass: 'drag-enter'