homepage Welcome to WebmasterWorld Guest from 54.198.224.121
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
HTML as plain text
amsmota




msg:596509
 6:07 pm on Jul 27, 2005 (gmt 0)

Hi:

I want to display some text that can have tags in it, but showing has plain-text, e.g.

<b>1234</b>

instead of

1234

I've tryed <pre> and <code> but won't do...

Thanks

 

encyclo




msg:596510
 6:20 pm on Jul 27, 2005 (gmt 0)

Welcome to the forums, amsmota.

You can replace the < and > with &lt; and &gt; respectively:

&lt;b&gt;1234&lt;/b&gt;

In HTML 3.2 there was the <xmp> tag which most browsers took to meaning that the contents should be unparsed, but the tag was deprecated and it probably isn't a good idea to depend on this behavior (which was not explicitly defined as such in the HTML 3.2 specification anyway).

<xmp><b>1234</b></xmp>

amsmota




msg:596511
 7:25 pm on Jul 27, 2005 (gmt 0)

Thanks, i'll look into it... For now i just put the all thing in a <textarea> but i don't know if it's ok this way.

Thanks a lot.

Herenvardo




msg:596512
 1:42 pm on Jul 28, 2005 (gmt 0)

First of all, welcome to webmasterworld, amsmota!
I agree with encyclo about using entities like &lt; and &gt;
In fact, entities where created with two purposes:
1: Allow 'stable' use of non-english characters (like ˝, š, Ó ˇ   and so on) and simbols that are not included in the 7-bit classic ASCII, to avoid misinterpretations among diferent language clients.
2: (The one that affects you) Allow use of 'reserved' characters, that is to get symbols like < and > shown instead of parsed.
So, I strongly encourage you to use entities for this, because they where created for this.

Hoping be useful,
Herenvard÷

PS: Everything about entities is published at [w3.org...] You may also seek the W3 Consortium specs to check entitites in the diferent versions of HTML. Even so, the ones you may need are also the ones most used and widely available: &lt; for <, &gt; for >, and don't forget to use &amp; for &, or the system might try to parse following text as an entity. Also care that these entities should be used even in tag's parameters, for example encoding the & in URI's.

Edited by Herenvardo. Edit reason: 'PS' added.

amsmota




msg:596513
 12:09 pm on Aug 2, 2005 (gmt 0)

Allright, thanks all for your help.

I just ended using jakarta commons StringEscapeUtils, that does exactly that...

Thanks.

kapow




msg:596514
 2:48 pm on Aug 2, 2005 (gmt 0)

Re. using entities like &lt; and &gt;

TIP: If you use DreamWeaver you can paste the code directly into the 'Design view' and DW will convert the code into things like &lt; and &gt;

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved