Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Display HTML hyperlink code as pure text?

Reply
Thread Tools

Display HTML hyperlink code as pure text?

 
 
Michael Jones
Guest
Posts: n/a
 
      09-11-2006
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


 
Reply With Quote
 
 
 
 
Beauregard T. Shagnasty
Guest
Posts: n/a
 
      09-11-2006
Michael Jones wrote:

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

--
-bts
-Motorcycles defy gravity; cars just suck.
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      09-11-2006
Michael Jones wrote:

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


http://allmyfaqs.net/faq.pl?Show_HTML_examples

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
mbstevens
Guest
Posts: n/a
 
      09-11-2006
On Mon, 11 Sep 2006 21:23:45 +0000, Michael Jones wrote:

> 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.
--
mbstevens
http://www.mbstevens.com


 
Reply With Quote
 
Michael Jones
Guest
Posts: n/a
 
      09-11-2006

"mbstevens" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) m...
> On Mon, 11 Sep 2006 21:23:45 +0000, Michael Jones wrote:
>
>> 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.
> --
> mbstevens
> http://www.mbstevens.com
>
>

To all the respondents:

Your solution worked perfectly - Thanks!

Michael Jones


 
Reply With Quote
 
Chris F.A. Johnson
Guest
Posts: n/a
 
      09-11-2006
On 2006-09-11, Michael Jones wrote:
> 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;'.

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      09-12-2006
Beauregard T. Shagnasty wrote:
> Michael Jones wrote:
>
>> 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;


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>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-12-2006
Toby Inkster <(E-Mail Removed)> scripsit:

> 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
translation engine _may_ treat <code> markup as indicating content that
should remain invariant in translation. Some engines do.

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

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pure space directly inside div ignored, but pure space directlyinside span honored liketofindoutwhy@gmail.com HTML 4 03-29-2008 06:06 PM
Pure functions still pure after definition Todd Aspeotis C++ 3 05-30-2005 03:53 AM
CHtmlView: How to read html text before display, change and give to display changed html code? Marek Kurowski C Programming 1 08-18-2004 06:41 PM
possible to manipulate pure HTML controls from code-behind? mike_bluestein@ya_StopSpammingMe_hoo.com ASP .Net Web Controls 0 11-03-2003 09:59 PM
possible to manipulate pure HTML controls from code-behind? Jeff ASP .Net 3 11-02-2003 09:18 PM



Advertisments