Display HTML hyperlink code as pure text?

Discussion in 'HTML' started by Michael Jones, Sep 11, 2006.

  1. 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
    Michael Jones, Sep 11, 2006
    #1
    1. Advertising

  2. 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.
    Beauregard T. Shagnasty, Sep 11, 2006
    #2
    1. Advertising

  3. 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
    David Dorward, Sep 11, 2006
    #3
  4. Michael Jones

    mbstevens Guest

    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
    mbstevens, Sep 11, 2006
    #4
  5. "mbstevens" <> wrote in message
    news:p...
    > 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
    Michael Jones, Sep 11, 2006
    #5
  6. 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)
    Chris F.A. Johnson, Sep 11, 2006
    #6
  7. Michael Jones

    Toby Inkster Guest

    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
    Toby Inkster, Sep 12, 2006
    #7
  8. Toby Inkster <> 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/
    Jukka K. Korpela, Sep 12, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff
    Replies:
    3
    Views:
    660
    Bucko
    Nov 2, 2003
  2. Todd Aspeotis
    Replies:
    3
    Views:
    461
    Kanenas
    May 30, 2005
  3. Marek Kurowski
    Replies:
    1
    Views:
    995
    Mark A. Odell
    Aug 18, 2004
  4. Replies:
    4
    Views:
    789
    Ben C
    Mar 29, 2008
  5. mike_bluestein@ya_StopSpammingMe_hoo.com

    possible to manipulate pure HTML controls from code-behind?

    mike_bluestein@ya_StopSpammingMe_hoo.com, Nov 3, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    149
    mike_bluestein@ya_StopSpammingMe_hoo.com
    Nov 3, 2003
Loading...

Share This Page