Solved

Show html text inside html

Posted on 2011-03-12
9
222 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
Comment Utility
use plaintext:
<plaintext><b>you can see all this code<b></plaintext>
 
0
 
LVL 4

Expert Comment

by:WhiteSeed
Comment Utility
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
Comment Utility
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
 

Author Comment

by:sandya_116
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
Comment Utility
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
Comment Utility
You can try using a converter: http://girlswhogeek.com/tools/2010/code-converter
0
 
LVL 33

Expert Comment

by:Todd Gerbert
Comment Utility
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
Comment Utility
you could use the tags
<pre></pre>

Open in new window

0
 
LVL 33

Expert Comment

by:Todd Gerbert
Comment Utility
<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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now