<!DOCTYPE html>
<html>
<body>

<p>Click the button to create a SECTION element containing a H1 and P element.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var x = document.createElement("SECTION");
    x.setAttribute("id", "mySection");
    document.body.appendChild(x);

    var heading = document.createElement("H1");
    var txt1 = document.createTextNode("Section Heading");
    heading.appendChild(txt1);
    document.getElementById("mySection").appendChild(heading);

    var para = document.createElement("P");
    var txt2 = document.createTextNode("Some text in section..");
    para.appendChild(txt2);
    document.getElementById("mySection").appendChild(para);
}
</script>

</body>
</html>