<!--
Title: How to create element dynamically in Javascript?
Tutorial: https://tutorial.tips/how-to-create-elements-dynamically-in-javascript
Author: Gulshan Saini 
Twitter: https://twitter.com/gulshansainis
-->
/*
Title: How to create element dynamically in Javascript?
Tutorial: https://tutorial.tips/how-to-create-elements-dynamically-in-javascript
Author: Gulshan Saini 
Twitter: https://twitter.com/gulshansainis
*/
/**
Title: How to create element dynamically in Javascript?
Tutorial: https://tutorial.tips/how-to-create-elements-dynamically-in-javascript
Author: Gulshan Saini 
Twitter: https://twitter.com/gulshansainis
*/

// create div element
let divElement = document.createElement('div');

// create text node
let divElementText = document.createTextNode("Dynamically created div element"); 

// append text node to div
divElement.appendChild(divElementText);

// append div element to document
document.body.appendChild(divElement);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.