The idea
The less-than sign begins a tag and the ampersand begins a character reference. Escape them when showing literal source code as text. code marks a code phrase; pre preserves spacing and line breaks. Escaping is about parsing correctly, not just appearance.
Worked example
<p>Write <code><h1></code> for a main heading.</p>
<pre><code>line one
indented line two</code></pre>
<p>Research & practice</p>What to check
The reader sees <h1> as text rather than a new heading element. pre retains the two spaces before the second line.
Practice task
Show a literal closing paragraph tag using character references, without creating another paragraph.
Check your understanding
Explain the result in your own words before changing the example. Change one thing at a time, compare the result with your prediction, and keep the version that demonstrates the concept clearly.