// .innerHTML method is used to change the html contents of a DOM object
document.getElementById("demo").innerHTML = "Paragraph changed!";
// Try to use `textContent` instead of innerHTML as innerHTML can be hacked.
document.getElementById("myHeader").textContent = "Heading"
document.getElementById("Test").innerHTML = "<p style='color:red;'>Test</p>";
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
//JavaScript can create dynamic HTML content:
<script>
document.getElementById("demo").innerHTML = "Date : " + Date(); </script>
</body>
</html>
<button onclick="this.innerHTML = Date()">The time is?</button>