homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

HTML as plain text

5+ Year Member

Msg#: 10707 posted 6:07 pm on Jul 27, 2005 (gmt 0)


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




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

Msg#: 10707 posted 6:20 pm on Jul 27, 2005 (gmt 0)

Welcome to the forums, amsmota.

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


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



5+ Year Member

Msg#: 10707 posted 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.


10+ Year Member

Msg#: 10707 posted 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,

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.


5+ Year Member

Msg#: 10707 posted 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...



WebmasterWorld Senior Member 10+ Year Member

Msg#: 10707 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved