How to display HTML code (entities) on a web page?

how do you write html code so that the user can see it on a web page (for example, as for html)

+3
source share
3 answers

encode your html objects:

< … &lt;
> … &gt;
& … &amp;
" … &quot;
(' … &apos; xml, not html. see comments)

you can also use

<pre><code>
here comes your preformatted and escaped &lt;html&gt;-code
</code></pre>

so that your code is monospaced and retains spaces

+11
source

You must use the HTML symbol characters &lt;and &gt;instead of <and>, so they are not interpreted as HTML-tags.

0
source

&apos;, &#39;.

0
source

Source: https://habr.com/ru/post/1717161/


All Articles