Solved

Show html text inside html

Posted on 2011-03-12
9
250 Views
Last Modified: 2012-05-11
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
Comment
Question by:sandya_116
9 Comments
 
LVL 4

Expert Comment

by:WhiteSeed
ID: 35117972
use plaintext:
<plaintext><b>you can see all this code<b></plaintext>
 
0
 
LVL 4

Expert Comment

by:WhiteSeed
ID: 35118034
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
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118047
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:sandya_116
ID: 35118089
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
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 35118095
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
 
LVL 2

Expert Comment

by:niralbhavsar
ID: 35118862
You can try using a converter: http://girlswhogeek.com/tools/2010/code-converter
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118867
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
 
LVL 8

Expert Comment

by:dmeeren
ID: 35121222
you could use the tags
<pre></pre>

Open in new window

0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35122841
<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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question