Solved

Show html text inside html

Posted on 2011-03-12
9
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Suggested Solutions

Title # Comments Views Activity
links not working 2 34
HTML editor custom button 3 87
Doubt with angularJs with PHP 4 19
Ordering displaying data in a drop down 3 4
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

739 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