Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brianellisrules

macrumors regular
Original poster
Oct 17, 2003
229
0
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?
 
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
 
Originally posted by mnkeybsness
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

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
 
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.
 
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.
 
Originally posted by Daveman Deluxe
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.

that's what i said... only more in depth and makes a little more sense when you explain it.
 
Originally posted by Daveman Deluxe
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.

Works in pretty much ever browser under the sun including Nutscrape, uhh i mean netscape 4 and IE 4.
 
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:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.