Preview:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="addElement()">Add new Element</button>
    <div id="container"></div>
    <script src="4_four_dom.js"></script>
</body>
</html>


function addElement(){
    let targetDiv = document.getElementById("container");
    function createElement(tag,className,id,content){
        let element = document.createElement(tag);
        if (className) element.className = className;
        if (id) element.id = id;
        if(content) element.content = content
        return element;
    }
    let main = createElement("section","section","section","this is new section");
    targetDiv.appendChild(main);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter