A community board prints a submitted note. The note is data, not markup: the browser must show its angle brackets literally.
textContent replaces a node’s children with plain text; angle brackets in the assigned string are displayed literally rather than parsed as tags. innerHTML parses the assigned string as HTML and can create elements, including unsafe markup when the string comes from a user. Reserve innerHTML for carefully controlled, trusted markup; do not use it for visitor input. Reading .textContent returns descendant text, including text in hidden descendants, rather than an HTML source string.
In script.js, this is the important part of the already-working preview:
const boardNote = document.querySelector("#board-note");
const visitorNote = "I brought <seedlings> today"; // Pretend this came from a form.
boardNote.textContent = visitorNote;
The preview shows the literal <seedlings> characters; there is no new seedlings element. Change the string to "<strong>hello</strong>" and Run again: you should see the tags printed, not bold text. Restore the original string afterward.
When a string comes from a person or remote data, which property keeps it as text? textContent. Why not innerHTML here? It would parse the string as markup.
The next lesson gives you a different page to build from a starter.