To insert an content before an element, you may find the the element to be inserted before, and use insertBefore method to insert the content. The next example is insert a horizontal line before the element 'main'.
var main, newElement;
main = document.getElementById('main');
if (main) {
newElement = document.createElement('hr');
main.parentNode.insertBefore(newElement, main);
}