Why document.writeln is considered bad practice

When debugging JavaScript code on pages Console sometimes complains about the use of document.writeln().

I used this in my footer to echo the date and time that the page was last changed. I also don't know why the document.writeln() only works if it enclosed within comment code and on a new line.

The code that I changed:

A HREF="#top"><<CRIPT><!--
	document.writeln(document.lastModified)
	--></SCRIPT></A>

was change to:

script>
document.getElementById("code").innerHTML = document.lastModified;
/script>

In addition if you click on the top-most code snippet it will change the section heading text. Also notice that the cursor will change to a pointer if placed over the snippet.

Links

External Sources

Is write(ln) bad? - January 2021