Display HTML hyperlink code as pure text?

M

Michael Jones

I would like to display some HTML hyperlink code as pure text on a web page
(ie I would like the user to be able to read the code).

I have tried to wrap the code in <code> tags but this does not seem to
work.

TIA
 
B

Beauregard T. Shagnasty

Michael said:
I would like to display some HTML hyperlink code as pure text on a web
page (ie I would like the user to be able to read the code).

I have tried to wrap the code in <code> tags but this does not seem
to work.

Convert all of the < to &lt;
and the > to &gt;
 
M

mbstevens

I would like to display some HTML hyperlink code as pure text on a web
page (ie I would like the user to be able to read the code).

I have tried to wrap the code in <code> tags but this does not seem to
work.


Use '&lt;' for '<' and '&gt;' for '>'.
That way, tags won't actually be interpreted as tags by the
visitor's browser. If you notice anything else in the code
not behaving in the way you expect, just use a character entity
or numeric entity instead of the character itself. If you google for
those two things you'll get more information.
 
M

Michael Jones

mbstevens said:
Use '&lt;' for '<' and '&gt;' for '>'.
That way, tags won't actually be interpreted as tags by the
visitor's browser. If you notice anything else in the code
not behaving in the way you expect, just use a character entity
or numeric entity instead of the character itself. If you google for
those two things you'll get more information.
To all the respondents:

Your solution worked perfectly - Thanks!

Michael Jones
 
C

Chris F.A. Johnson

I would like to display some HTML hyperlink code as pure text on a web page
(ie I would like the user to be able to read the code).

I have tried to wrap the code in <code> tags but this does not seem to
work.

Either rename the file (or a copy of it) with a .txt instead of
.html extension (you can use a link on a Unix system), or change
all instances of '<' to '&lt;' and '&' to '&amp;'.
 
T

Toby Inkster

Beauregard said:
Convert all of the < to &lt;
and the > to &gt;

You should probably still keep the <code>...</code> tags though -- as this
lets browsers know that you're displaying some source code. They can then
choose an appropriate way of displaying it -- often in a fixed-width font,
but perhaps in an audio browser, read by a different voice, or on systems
with only one font, in a different colour.

<code>&lt;A HREF="http://www.google.co.uk/"&gt;Google&lt;/A&gt;</code>
 
J

Jukka K. Korpela

Toby Inkster said:
You should probably still keep the <code>...</code> tags though -- as
this lets browsers know that you're displaying some source code.

Besides, if the page is submitted to automatic translation, then the
<code>&lt;A HREF="http://www.google.co.uk/"&gt;Google&lt;/A&gt;</code>

Some people would say that these days, one should not use uppercase letters
in element and attribute names, since they are disallowed in XHTML.

The use of &gt; for > is merely a common practice for symmetry. There is no
need to "escape" > in HTML. The days when some browsers got this wrong have
gone long ago.

Anyway, as I have often replied in response to the oft-repeated question
"how do I show HTML code on my page", I'd like to tell the OP that if he had
to ask, he's probably not qualified to give others advice on using HTML
markup on his pages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top