Is there a way to add tags in the <code> tag?

Hi!
I’m trying to make my text appear in code form using <code>, like this:

<code>
        <p>This is and example of an element</p>
</code>

But when I run the code, I get just the text appearing like code, and not the p tag. So I had to put it like this to work:

 <code>
      <code><</code><code>p</code><code>></code>This is an example of an element<code><</code><code>/</code><code>p</code><code>></code>
 </code>

I was wondering if there is another way of doing this, or is this the only way? Would I have to do this for longer opening and closing tags too?

you need to use the symbols &lt; and &gt; to not have the tags disappear

1 Like

Thank you! This helped