• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Show html text inside html

I need to show html text inside html code but it converting the text to html. For example the text "<b>bold text<b/> and &#38;" is placed inside a font tag like <font></font>. I want it to display as plain text rather than html converted text. Thanks.
0
sandya_116
Asked:
sandya_116
1 Solution
 
WhiteSeedCommented:
use plaintext:
<plaintext><b>you can see all this code<b></plaintext>
 
0
 
WhiteSeedCommented:
i think now that with plaintext you can have problem with the close tag. you can use this system:

Instead of using a < sign, use the code
&lt;
Instead of using a > sign, use the code
&gt;
0
 
Todd GerbertIT ConsultantCommented:
The <plaintext> tag may not work as expected, e.g. on my up-to-date FireFox the closing </plaintext> tag is not recognized, thus everything after the opening tag is shown as plain text.

You will probably need to encode the special characters:

<font size="3" color="red">&lt;b&gt;you can see all this code, &amp;#38&lt;/b&gt;</font>

Open in new window


This website has a tool that will convert text for you: http://www.opinionatedgeek.com/dotnet/tools/htmlencode/encode.aspx
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sandya_116Author Commented:
well the text is dynamically loaded so there could be bunch of characters that need to be encoded. Is there something else like plaintext tag.
0
 
Todd GerbertIT ConsultantCommented:
Well, if it's an ASP.Net web site you can HTML encode text on-the-fly with the Server.HtmlEncode() method, or using client-side JavaScript with the escape() method.
0
 
niralbhavsarCommented:
You can try using a converter: http://girlswhogeek.com/tools/2010/code-converter
0
 
Todd GerbertIT ConsultantCommented:
I think a converter was already suggested, and doesn't do any good anyway since text is added to the page at run-time. ;)
0
 
dmeerenCommented:
you could use the tags
<pre></pre>

Open in new window

0
 
Todd GerbertIT ConsultantCommented:
<pre> tags won't work; they'll effectively remove any other HTML tags contained within them, and force the font to a fixed-width one, and since the asker specified the text to be displayed is inside a <font> tag I assume that's because he wants control over the font used.

"<font face="Tahoma"><pre><b>Hello World</b></pre></font>" will get you output that looks like:
Hello World

Open in new window


Whereas "<font face="Tahoma">&lt;b&gt;Hello World&lt;/b&gt;</font>" will get you output like:
<b>Hello World</b>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now