// Get the element you want to add your new element before or after
var target = document.querySelector('#some-div');
// Create the new element
// This can be any valid HTML element: p, article, span, etc...
var div = document.createElement('div');
// Add content to the new element
div.innerHTML = 'Your content, markup, etc.';
// You could also add classes, IDs, and so on
// div is a fully manipulatable DOM Node
// Insert the element before our target element
target.parentNode.insertBefore( div, target );
// Insert the element after our target element
target.parentNode.insertBefore( div, target.nextSibling );