Search code examples
htmlpre

How to show span tag using pre tag without css


I need to show this entire text in an HTML page:

<span class='per-amount' role='text' aria-label='1,496 undefineds'><span class='per-curr'>₪</span><span class='per-minus-sign'></span><span class='per-int-num'>1,496
</span><span class='per-decimals-dot'></span><span class='per-decimals'></span></span>

I tried to show this entire text by wrapping it with pre tag, but is didn't work.

<pre><span class='per-amount' role='text' aria-label='1,496 undefineds'><span class='per-curr'>₪
</span><span class='per-minus-sign'></span><span class='per-int-num'>1,496</span><span class='per-decimals-dot'></span><span class='per-decimals'></span></span></pre>

Is there a way to force the browser to show it, without using CSS?


Solution

  • You could use xmp instead of pre, but do note that it's deprecated since HTML3.2 and obsolete as of HTML5 – although it still seems to work in all major browsers:

    <xmp><span class='per-amount' role='text' aria-label='1,496 undefineds'><span class='per-curr'>₪
    </span><span class='per-minus-sign'></span><span class='per-int-num'>1,496</span><span class='per-decimals-dot'></span><span class='per-decimals'></span></span></xmp>

    Your other option would be to change less-thans to &lt;, but that could require preprocessing or JavaScript.