Let's talk about validation for a second...

Discussion in 'Web Design and Development (archive)' started by brianellisrules, Dec 31, 2003.

  1. macrumors regular

    Joined:
    Oct 17, 2003
    #1
    Hello all. I'm bored at work so I figured I'd go through and validate all my webpages and whatnot. (Yeah, I'm *that* bored)

    Anyhoo, I'm cruising along and everything is up to snuff for the most part, but then I try to validate my Christmas List...

    http://www.brianellisrules.com/stories/?story=xmaslist

    Turns out, the validator doesn't like all the links to amazon.com. What's up with that?
     
  2. macrumors 68030

    mnkeybsness

    Joined:
    Jun 25, 2001
    Location:
    Moneyapolis, Minnesota
    #2
    the validator does that because some special characters are used such as the ampersand '&' etc...

    for valid html, you need to use the name codes

    unfortunately, the links will not work if you do that... it's kind of a php issue more than html... everything should work fine though even though it's not valid
     
  3. macrumors 65816

    mrjamin

    Joined:
    Feb 6, 2003
    Location:
    Strongbadia
    #3
    eh? links should work absolutely fine! all my recent sites are valid XHTML, and have not had any problems with links in every browser i've tried. htmlspecialchars() or htmlentities() on a url will sort out all the ampersands in querystrings etc.

    edit: added links to php.net for functions
     
  4. thread starter macrumors regular

    Joined:
    Oct 17, 2003
    #4
    The links are straight HTML code copied and pasted from the amazon.com webpage... there's no PHP involved there. I'm just wondering why they're not valid... I'm guessing the validator just flakes out on the long links.
     
  5. macrumors 68000

    Daveman Deluxe

    Joined:
    Jun 17, 2003
    Location:
    Corvallis, Oregon
    #5
    It's not the length of the URI that the validator is pissed off about. In (X)HTML, the ampersand (&) character is used to denote the beginning of a character entity reference. In your page, the characters immediately after the ampersand do not refer to a character entity and there is no terminating semicolon. However, it's not going to cause you any problems because they are in URIs and not in page text.

    By the way, if you're writing a webpage, do not type an actual ampersand into the text. Use the character entity reference "&" instead. Don't try to do it in URIs though.

    It's a PHP issue because the web pages you are linking to are PHP and they use ampersand-delineated URIs as part of its system for submitting search/item requests.

    This is one of those cases where the validators aren't perfect. It shouldn't be hard for a validator to ignore illegal characters in element attributes, but they aren't there yet.

    Edit: On second glance, replacing ampersands with "&" will still link to the proper page, at least in Safari. I'm not positive about other browsers though.
     
  6. macrumors 68030

    mnkeybsness

    Joined:
    Jun 25, 2001
    Location:
    Moneyapolis, Minnesota
    #6
    that's what i said... only more in depth and makes a little more sense when you explain it.
     
  7. macrumors 65816

    mrjamin

    Joined:
    Feb 6, 2003
    Location:
    Strongbadia
    #7
    Works in pretty much ever browser under the sun including Nutscrape, uhh i mean netscape 4 and IE 4.
     
  8. macrumors 68000

    Daveman Deluxe

    Joined:
    Jun 17, 2003
    Location:
    Corvallis, Oregon
    #8
    Stupid me. When typing out character entity references in my earlier post, it converted them to proper ampersands. :rolleyes:

    Edit: It still didn't work. Let's try it this way:

    & a m p ;

    Remove the spaces between each character when you do it for real, of course. :D :rolleyes:
     

Share This Page