In this article, I teach you how to write HTML markup inside JS.

This method returns HTML element content like innerText and textContent if any HTML element is available inside that element text then innerHTML returns that element along with its content as a normal text.

HTML element and JS innerHTML

It seems like innerText but it’s not accurate. As I mentioned yesterday we can alter the content of an HTML element in JS via DOM methods.

For example, if you want to write Hello friend and the friend word must be in the bold format you can achieve this via innerHTML inside JS.

This renders the friend word into a bold format according to HTML elements rendering.

It comes in handy when working with API to fetch data from an API and display it into the browser’s window.

innerHTML has a security issue when using it fortunately more ways or methods are available to create an HTML element inside JS and then assign our content to it.

You’ll learn about how to create HTML elements inside JS later on.

For more info about innerHTML refer to MDN or w3schools

I know a little about innerHTML if you know anything more about innerHTML please let me know in the comment below. 👋

I am a web developer who writes web development content for you to make web development easier