Why isn't there a document.createHTMLNode()?

Because "<h1>test</h1>some more text" consists of an HTML element and two pieces of text. It isn't a node.

If you want to insert HTML then use innerHTML.

Is there a way to do this without getting an extra html-element around the html i want to insert?

Create an element (don't add it to the document). Set its innerHTML. Then move all its child nodes by looping over foo.childNodes.


In some browsers (notably not any version of IE), Range objects have an originally non-standard createContextualFragment() that may help. It's likely that future versions of browsers such as IE will implement this now that it has been standardized.

Here's an example:

var frag = range.createContextualFragment("<h1>test</h1>some more text");
range.insertNode(frag);

Instead of innerHTML just use appendChild(element); this may help you. If you want comment here, and I will give you an example.