Click here to get back home

Showing html code in a web page

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Showing html code in a web page Armand Karlsen 04-03-2005
Posted by Armand Karlsen on April 3, 2005, 5:56 pm
Please log in for more thread options


What code can I put in a web page to make a browser show a piece of (x)html,
instead of trying to render it?




Posted by Arne on April 3, 2005, 7:15 pm
Please log in for more thread options


Once upon a time *Armand Karlsen* wrote:
> What code can I put in a web page to make a browser show a piece of (x)html,
> instead of trying to render it?
>

You replace < and > with &lt; and &gt; in the html for e.g
&lt;img src="yourimage.jpg" alt="alt text" /&gt; and it will look like
<img src="yourimage.jpg" alt="alt text" /> on the page

--
/Arne
*I don't reply to top posters!*


Posted by Stan Brown on April 3, 2005, 5:04 pm
Please log in for more thread options


"Arne" wrote in comp.infosystems.www.authoring.html:
>Once upon a time *Armand Karlsen* wrote:
>> What code can I put in a web page to make a browser show a piece of (x)html,
>> instead of trying to render it?
>>
>
>You replace < and > with &lt; and &gt; in the html for e.g
>&lt;img src="yourimage.jpg" alt="alt text" /&gt; and it will look like
><img src="yourimage.jpg" alt="alt text" /> on the page

The above is step 2.

Step 1: Replace any & with &amp;

Step 3: Slap <pre> above the snippet and </pre> below it.


If you want to show a whole page of HTML as text, it's best to tell
your server to offer it as text/plain. Then you don't need to
change a single character. (Does MSIE still ignore "text/plain" and
try to render a page if its name happens to end in ".htm"?)

--

Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/


Posted by Jukka K. Korpela on April 3, 2005, 8:28 pm
Please log in for more thread options



> What code can I put in a web page to make a browser show a piece of
> (x)html, instead of trying to render it?

If you need to ask, do you think you are competent enough in XHTML
to present HTML code in public? During the years, we have even seen
people who claim to be writing an HTML tutorial and asked how to show
HTML samples. The usual advice is: read a good tutorial before trying
to write one.

(Any good tutorial tells that the characters "<" and "&", if they
appear as data, should be written as "&lt;" and "&amp;", or something
like that. But a good tutorial tells you other things as well, such as
the use of <code> markup and various ways to preserve formatting,
should you wish to do do.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html



Similar ThreadsPosted
Showing the html? March 15, 2007, 11:20 am
Can I sort a file from an ASP code page? October 18, 2005, 5:53 am
Share common HTML code among different HTML files? May 14, 2005, 11:05 pm
changes in HTML code are ignored by the browser (IE6) October 7, 2004, 11:56 am
Self-modifying HTML code? August 17, 2006, 11:53 am
html email displays as code June 27, 2007, 4:19 pm
Re: Make HTML code show up on the web April 15, 2008, 8:06 am
html validation - html code help February 3, 2006, 12:50 pm
how to set browser window attributes in this HTML code? March 21, 2005, 9:12 am
Translating foreign characters to HTML code June 25, 2005, 2:35 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap