开发者

Ampersands in hyperlinks cause W3C validation to fail

开发者 https://www.devze.com 2022-12-24 01:46 出处:网络
I have a reacurring problem. I code nice standards compliant code only to have it fail开发者_如何学编程 due to ampersands within some of the hyperlink urls.

I have a reacurring problem. I code nice standards compliant code only to have it fail开发者_如何学编程 due to ampersands within some of the hyperlink urls.

Does anyone know of a work around or hack for this.

Thanks


I code nice standards compliant code only to have it fail due to ampersands within some of the hyperlink urls.

Unescaped ampersands in URLs (or anywhere else, if they're not part of an HTML entity!) aren't "nice standards compliant code".

Turn them into & and you can accurately claim to have done this.


Did you make them & in the links like this?

&


You should URL Encode the hyperlinks, so all characters are turned into a valid ASCII format and don't contain any (X)HTML entities.

For C# use HttpUtility.UrlEncode, for PHP urlencode, for JavaScript encodeURI, etc... Finding the right method for the language you're using shouldn't be that hard.


CDATA works wonders where you have & in javascript strings..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号