HTML Creation
One of the most common uses for JavaScript is to create HTML element. Creating HTML with JavaScript can involve creating a single tag or the entire page. There are two common ways to create HTML using JavaScript. One is to use the createElement()
function. The other is to use an HTML string with innerHTML
property or the insertAdjacentHTML()
method.
While best practice states that the former is the preferred technique, due to its significantly better performance, it is also much more complex and difficult to use for novice developers. Furthermore, real-world benefits are marginal. For that reason in this course, we will be focusing on creating new HTML elements using strings.