Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <p>Click the button to create an ARTICLE element containing a H1 and P element.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("ARTICLE"); x.setAttribute("id", "myArticle"); document.body.appendChild(x); var heading = document.createElement("H1"); var txt1 = document.createTextNode("Heading in Article"); heading.appendChild(txt1); document.getElementById("myArticle").appendChild(heading); var para = document.createElement("P"); var txt2 = document.createTextNode("Paragraph in article."); para.appendChild(txt2); document.getElementById("myArticle").appendChild(para); } </script> </body> </html>