& in links

Discussion in 'HTML' started by Matthew, Jul 1, 2004.

  1. Matthew

    Matthew Guest

    I just ran a HTML validator on one of my web sites. It said that the
    following is invalid:
    <A HREF="products.cfm?type=Specialty&id=8">
    and should be written:
    <A HREF="products.cfm?type=Specialty&amp;id=8">

    Does anybody know how serious this is?
    Also, I am considering putting the following line at the top of every page:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    Will this affect the decision about &amp; in links?

    Thanks in advance,

    Matthew
     
    Matthew, Jul 1, 2004
    #1
    1. Advertising

  2. Matthew

    Steve Pugh Guest

    "Matthew" <> wrote:

    >I just ran a HTML validator on one of my web sites. It said that the
    >following is invalid:
    ><A HREF="products.cfm?type=Specialty&id=8">
    >and should be written:
    ><A HREF="products.cfm?type=Specialty&amp;id=8">
    >
    >Does anybody know how serious this is?


    Do you want valid code or not? If you do then you should change it.

    >Also, I am considering putting the following line at the top of every page:
    ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    >"http://www.w3.org/TR/html4/strict.dtd">
    >
    >Will this affect the decision about &amp; in links?


    No.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jul 1, 2004
    #2
    1. Advertising

  3. "Matthew" <> writes:

    > I just ran a HTML validator on one of my web sites. It said that the
    > following is invalid:
    > <A HREF="products.cfm?type=Specialty&id=8">


    Try a reference to a declared entity, eg

    <A HREF="products.cfm?type=Specialty&copy=2004">

    > and should be written:
    > <A HREF="products.cfm?type=Specialty&amp;id=8">
    >
    > Does anybody know how serious this is?


    If you try the above, you'll see that it is valid but perhaps not just
    what you expected; this issue has been discussed until the cows came
    home. Try Google.

    > Also, I am considering putting the following line at the top of every page:
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">


    Fine. Why?

    > Will this affect the decision about &amp; in links?


    No. Thanks to doctype sniffing bogosity it is not quite impossible that
    UA behaviour might differ when parsing URI references with undeclared or
    existing entities, though.


    --
    | ) 111010111011 | http://bednarz.nl/
    -(
    | ) Distribute me: http://binaries.bednarz.nl/mp3/aicha
     
    Eric B. Bednarz, Jul 1, 2004
    #3
  4. Matthew

    Neal Guest

    On Thu, 1 Jul 2004 16:58:42 -0400, Matthew <>
    wrote:

    > ... I am considering putting the following line at the top of every page:
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">
    >


    What's to consider? To code HTML 4.01 strict you need that to gain the
    benefit of quirk-less rendering.
     
    Neal, Jul 2, 2004
    #4
  5. Matthew

    DU Guest

    Steve Pugh wrote:
    > "Matthew" <> wrote:
    >
    >
    >>I just ran a HTML validator on one of my web sites. It said that the
    >>following is invalid:
    >><A HREF="products.cfm?type=Specialty&id=8">
    >>and should be written:
    >><A HREF="products.cfm?type=Specialty&amp;id=8">
    >>
    >>Does anybody know how serious this is?

    >
    >
    > Do you want valid code or not? If you do then you should change it.
    >


    I'd like to reply to this. I entirely agree with the purpose of writing
    entirely valid code as much as possible (if not always) but...
    I was once asked why+how not writing &amp; in an uri would affect a
    webpage, would cause problems or bugs or anything and I couldn't come up
    with an answer. It seems that almost no matter how you write an uri,
    browsers succeed in overcoming this very very frequent validation error.
    I am just wondering, like I was asked, how this error affects webpages
    or affects browsers. There must be somewhere a problem caused by not
    escaping ampersand characters and/or there must be a benefit somehwere
    for escaping, converting ampersand characters into &amp;: so, what is it?

    DU

    >
    >>Also, I am considering putting the following line at the top of every page:
    >><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    >>"http://www.w3.org/TR/html4/strict.dtd">
    >>
    >>Will this affect the decision about &amp; in links?

    >
    >
    > No.
    >
    > Steve
    >
     
    DU, Jul 3, 2004
    #5
  6. Matthew

    Steve Pugh Guest

    DU <> wrote:
    >Steve Pugh wrote:
    >> "Matthew" <> wrote:
    >>
    >>>I just ran a HTML validator on one of my web sites. It said that the
    >>>following is invalid:
    >>><A HREF="products.cfm?type=Specialty&id=8">
    >>>and should be written:
    >>><A HREF="products.cfm?type=Specialty&amp;id=8">
    >>>
    >>>Does anybody know how serious this is?

    >>
    >> Do you want valid code or not? If you do then you should change it.

    >
    >I'd like to reply to this. I entirely agree with the purpose of writing
    >entirely valid code as much as possible (if not always) but...
    >I was once asked why+how not writing &amp; in an uri would affect a
    >webpage, would cause problems or bugs or anything and I couldn't come up
    >with an answer. It seems that almost no matter how you write an uri,
    >browsers succeed in overcoming this very very frequent validation error.
    >I am just wondering, like I was asked, how this error affects webpages
    >or affects browsers. There must be somewhere a problem caused by not
    >escaping ampersand characters and/or there must be a benefit somehwere
    >for escaping, converting ampersand characters into &amp;: so, what is it?


    What happens if the sequence following the & is a character entity
    reference? The browser will convert that to the relevant character,
    thus changing the URL.

    <a href="script.cgi?id=234&prod=234&sect=234"> looks like a perfectly
    sound URL but as &prod and &sect are both HTML 4 character entity
    references it's actually a different URL.

    Can you remember all the character entity references and avoid using
    them as parameter names? Easier and safer to write &amp;.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Jul 3, 2004
    #6
    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. DC Gringo
    Replies:
    3
    Views:
    6,217
    mikeb
    Aug 19, 2004
  2. DC Gringo

    encoding of "&" vs "&amp;" in url

    DC Gringo, Aug 4, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    17,057
    davitz38
    Feb 5, 2010
  3. Replies:
    1
    Views:
    739
    Rosanne
    Oct 11, 2005
  4. FoundThisOnline

    &amp; problem with hyperlink control

    FoundThisOnline, Oct 11, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    2,919
    FoundThisOnline
    Oct 11, 2005
  5. Thomas Scheffler

    XALAN and &amp; in links

    Thomas Scheffler, Jan 5, 2005, in forum: XML
    Replies:
    0
    Views:
    421
    Thomas Scheffler
    Jan 5, 2005
Loading...

Share This Page