Html “& 没有开始字符引用。(& 可能应该被转义为 &。)” w3c 标记

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15970738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:29:09  来源:igfitidea点击:

"& did not start a character reference. (& probably should have been escaped as &.)" w3c markup

htmlw3c-validation

提问by codebox

I'm using w3c markup validator. I get this error:

我正在使用 w3c 标记验证器。我收到此错误:

Line 169, Column 60: & did not start a character reference. (& probably should have been escaped as &.)
    <a href="index.php?option=com_content&view=article&id=6&Itemid=4">

If I use &amp instead of &, I can't pass values to next page. Someone please help me. Thanks in advance

如果我使用 & 而不是 &,则无法将值传递到下一页。有人请帮助我。提前致谢

回答by codebox

Did you include the semi-colon after &amp? Your link should be

你在后面加了分号&amp吗?你的链接应该是

<a href="index.php?option=com_content&amp;view=article&amp;id=6&amp;Itemid=4">

Note that if you paste this url into the address bar of your browser it won't work - the browser converts the &amp;into &when you click the link in the page.

请注意,如果您将此 url 粘贴到浏览器的地址栏中,它将不起作用 -当您单击页面中的链接时,浏览器会将其转换&amp;&

回答by Pete Klein

The value of an href attribute should be url encoded, not html encoded:

href 属性的值应该是 url 编码的,而不是 html 编码的:

<a href="index.php?option=com_content%26view=article%26id=6%26Itemid=4">