2

im looking for a way to show html as html without the browser reading it, i found <plainttext> but once i start it i can't stop it for example:

<plaintext>
    <span> dobeediedabiedadadee olleeeeee</span>
</plaintext>
<h1>hi</h1>

in this example the span had to be shown as text and the h1 as a header, but the output is:

    <span> dobeediedabiedadadee olleeeeee</span>
</plaintext>
<h1>hi</h1>

</body>


</html>

here a JSFiddle link: JSFiddle

a other solution as plaintext is also welcome thanks for your time.

user2389793
  • 315
  • 1
  • 3
  • 8

6 Answers6

4

plaintext has long been deprecated, just use &gt; and &lt;

&lt;span&gt; dobeediedabiedadadee olleeeeee&lt;/span&gt;

DEMO: Fiddle

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
1

You could always use javascript to escape the HTML. Here is a fiddle.

html.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
Community
  • 1
  • 1
John
  • 13,197
  • 7
  • 51
  • 101
0

The following link describes the difficulty in using <plaintext>. long story short it is not fully supported in any browser and you should be using <pre> instead.

http://reference.sitepoint.com/html/plaintext

Simon McLoughlin
  • 8,293
  • 5
  • 32
  • 56
0

<plaintext> is not a pair tag. From that tag to the rest of the page, everything is interpreted as text. However, this is not standard and obsolette in HTML5:

Examples No, really. don't use it.

It is literally written in the w3 reference

Jan Turoň
  • 31,451
  • 23
  • 125
  • 169
0

it is compatibility issue some browser completely ignores coding of

have a look at this link http://reference.sitepoint.com/html/plaintext

i would suggest you use instead

0

Use PRE

<pre>
    <span> dobeediedabiedadadee olleeeeee</span>
</pre>
<h1>hi</h1>
Serge
  • 6,554
  • 5
  • 30
  • 56