When you use appendChild() method to append some content , by default it inserts inside the selected html element. But if you want to add html element before the selected element, then you will learn in this article, how you can add html element before some elements using javascript.

The insertBefore() method inserts HTML elements before the selected element.

If you want to insert HTML elements after the selected element, then use the insertAfter() method.
Example of insertBefore() Method