By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,807 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

Showing html code in a web page

P: n/a
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?
Jul 24 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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!*
Jul 24 '05 #2

P: n/a
"Armand Karlsen" <ar************@zen.co.uk> 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?


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

Jul 24 '05 #3

P: n/a
"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/
Jul 24 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.