Check out example codes for "js create html element". It will help you in understanding the concepts better.

Code Example 1

<div id="div1">
  <p id="p1">This is a paragraph.</p>
  <p id="p2">This is another paragraph.</p>
</div>

<script>
var para = document.createElement("P");//make an p element
var node = document.createTextNode("This is new.");//create an innerhtml node
para.appendChild(node);//add the text to the p element

var element = document.getElementById("div1");//search the div1
var child = document.getElementById("p1");//search the first p element
element.insertBefore(para, child);//inserts the p element before the first paragraph
</script>

Code Example 2

var img = document.createElement('img');

Code Example 3

let p = document.createElement('p');

Code Example 4

<div id="new">
<p id="p1">Tutorix</p>
<p id="p2">Tutorialspoint</p>
</div>
<script>
   var tag = document.createElement("p");
   var text = document.createTextNode("Tutorix is the best e-learning platform");
   tag.appendChild(text);
   var element = document.getElementById("new");
   element.appendChild(tag);
</script>

Code Example 5

var newDiv = document.createElement("div");
document.body.appendChild(newDiv);

Learn ReactJs, React Native from akashmittal.com