Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Numeric character references in href tags

    Can anyone tell me if it's acceptable or otherwise to use & as an escape character for an ampersand in an href tag.

    The coding standards here "encourage" the use of numeric character references, supposedly because they're not so English-language dependent, but the link checking software we use doesn't like them. The software vendors claim that their use is "illegal", citing the RFC1738 standard (which I'm not sure I fully understand). The software can't distinguish between a hash character used as part of a fragment identifier and a hash character used as part of a numeric character reference.

    However, online validators provided by W3C and WDG (for example) seem to accept their use. The attached file - designed to be an HTML one - provides examples that can be tested (it has links to the validators).

    Thanks in anticipation of the enlightenment to follow.
    Attached Files Attached Files

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Numeric character references in href tags

    That's an old RFC (1994) and since that time the web has become more multilingual. Perhaps your link checking software needs to be updated??

    Anyway, I think <code>&amp;</code> probably is a global standard...

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Numeric character references in href tags

    Thanks for the reply. I guess that "internet standards" is still something of an oxymoron.

  4. #4
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Numeric character references in href tags

    <img src=/S/yep.gif border=0 alt=yep width=15 height=15> Oh yes.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Numeric character references in href tags

    Hi William

    This post is about 6 weeks old now but I just wanted to add my little experience from tonight. I was just updating my website with a few new useful and interesting links and I went off to a site which I thought was interesting and copied the URL into my page part of the url was :

    ...?CurrentPage=1&;rhs"

    This was quite happily accepted by the site as expected but my caveat and warning is that I always get my website validated by W3C against the xhtml1-transitional.dtd...long story why but I teach the subject and have to be seen to practice what I teach. Anyway, back to the point my page would not validate purely because of the &, I therefore use the following:

    ...?CurrentPage=1& amp;rhs" (space before amp there so Lounge Parser can view the code)

    and it was interpreted correctly, looks like W3C is getting strict now and just a top tip to add to yours.
    Jerry

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Numeric character references in href tags

    I agree. W3C and others provide good online validators that I also use as a matter of course - even though they are pedantic at times (especially the CSS ones).

  7. #7
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Numeric character references in href tags

    >even though they are pedantic at times (especially the CSS ones). <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    ...but isn't it wonderful when you get it right...I have students shout "YEESSSSS" when they accomplish it for the first time and it is still fulfilling even now.

    Seriously though the CSS one is hard but very satisfying, hence why I try and stick to the same generic model CSS and chop and change the requirements. It is the hacks that are the pain.
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •