Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

HTML as plain text



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

10+ Year Member


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


instead of


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



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

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to the forums, amsmota.

You can replace the



In HTML 3.2 there was the

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).



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

10+ Year Member

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.


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

10+ Year Member

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,

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.


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

10+ Year Member

Allright, thanks all for your help.

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



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

WebmasterWorld Senior Member 10+ Year Member

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;


Featured Threads

Hot Threads This Week

Hot Threads This Month