Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 1.4 — Comments, Whitespace and Character Entities
HTML · Example 3 of 3

Escaping keeps user text as text

textContent treats the visitor's text as plain text: the browser escaped <, > and & for you, so the tags show literally and nothing runs.

Comments are notes in your HTML that the page doesn't show; character entities like &lt; and &amp; let you show characters that HTML would otherwise treat as code, which is also the basis of safe escaping.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a paragraph that shows exactly this text: Use <h1> once & only once.

02

Write a footer paragraph with a copyright sign, the year, the name Hectal, and a non-breaking space between Page and 1.

03

Add a comment above a heading explaining that it must match the page title.

Explain it without notes

01

Why do you need &lt; and &amp;? What goes wrong without them?

02

Are HTML comments safe for private notes? Why or why not?

03

What is the difference between a named entity and a numeric entity?

04

How does escaping protect a site against cross-site scripting?

Escaping keeps user text as text

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

Shown: I <b>love</b> this & that
Stored as HTML: I &lt;b&gt;love&lt;/b&gt; this &amp; that