> For the complete documentation index, see [llms.txt](https://docs.novarietygames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.novarietygames.com/websitecreator/luascript/dom/elements/insertbefore.md).

# insertBefore

The **`insertBefore()`** method adds a Element to the end of the list of children of a element.

**Example**

<pre class="language-lua"><code class="lang-lua">local name = window.input("What is your name?","My name is ...")
<strong>local elm = document.createNode("p",{style="color:red"},string.format("Welcome %s",name))
</strong>document.querySelector("body").insertBefore(elm,1) -- Inserts at the front
</code></pre>
