-2

When I want to write blog that is showing some sample code, I normally use the <code> element eg.

<pre>
  <code>
    some code here
    some more code
  </code>
</pre>

However this does not work if the sample code is html e.g.

<pre>
  <code>
    <div id="target"></div>
  </code>
</pre>

Doing this just produces a blank code block. How do I do this?

Obromios
  • 15,408
  • 15
  • 72
  • 127

1 Answers1

0

One way is to replace the < and > brackets with &lt; and &gt;.

<pre>
  <code>
    &lt;div class="target"&gt;&lt;/target&gt;
  </code>
</pre>

Will render:

  
    <div class="target"></target>
  
thingEvery
  • 3,368
  • 1
  • 19
  • 25