[ACCEPTED]-HTML tag to prevent HTML tags to be executed?-xhtml

Accepted answer
Score: 10


The html code for < is <

Renders as:

The html code for < is 2 &lt;

The basic strategy is to escape 1 the & as &amp;

Score: 9

You are going to have to do it manually.

Here you 2 have the full encoding table. The most commonly 1 used codes are:

Character  Entity Number  Entity Name  Description
"          &#34;          &quot;       quotation mark
'          &#39;          &apos;       apostrophe (does not work in IE)
&          &#38;          &amp;        ampersand
<          &#60;          &lt;         less-than
>          &#62;          &gt;         greater-than
Score: 6

In this case, you DON'T need to encode it. Try 2 this one:

<xmp> html < &lt; </xmp>

I'm not sure about cross browsers 1 support, but works on IE7,FF3,Chrome3

Score: 4

I suppose you don't want the entity to be 2 rendered? If you want to display &lt; you'll 1 have to use the entity for the ampersand: &amp;.

Score: 1

The html code for < is &lt;

That is, type 1 &lt; is &amp;lt;.

Score: 1

If you have access to server side scripting 4 capabilities, you might be able to use utility 3 functions of that platform. For example, in 2 PHP you might use the htmlentities function to your 1 advantage:

echo htmlentities("The html code for < is &lt;");
Score: 0

You could use a <pre> &lt; </pre> sequence


Score: 0

You need to encode it. For example, '<' = '&lt;'

Here 2 is the list.

So in your case it will end up like 1 this:

The html code for &lt; is &amp; l t ;
Score: 0
<textarea readonly rows="2" cols="50" style="border:none; color:lightGray; background-color:black;">

is the only supported option . but its not 6 enabled neither here neither on GitHub .

i'm 5 5min with HTML, so also would appreciate 4 anyone enhancing it with dynamic size, achieved 3 trough the tag's HTML/CSS attributes, or, if 2 its not possible, trough a small embed Java 1 Script .

More Related questions