简体   繁体   English

'a'标签中标题属性末尾的空格

[英]Space at the end of title attribute in 'a' tag

I have a link like this: 我有这样的链接:

<a title="Lorem ipsum " href="http://example.com">Lorem ipsum</a>

Important is the space at the end of title attribute. 重要的是标题属性末尾的空格。 If this link comes to the browser, it will change to this: 如果此链接到达浏览器,它将更改为:

<a title="Lorem ipsum " &nbsp;href="http://example.com">Lorem ipsum</a>

This is not valid link so it do not work. 这是无效的链接,因此无效。 It is not a JavaScript problem, it is not working in Firefox 44.0.2 and Chrome 48.0.2564.116 (64-bit). 这不是JavaScript问题,在Firefox 44.0.2和Chrome 48.0.2564.116(64位)中不起作用。 W3C validator throws an error saying that "Attribute href not allowed on element a at this point.". W3C验证器引发错误,指出“此时元素a上不允许使用href属性”。 Why is a space at the end of title attribute a problem? 为什么标题属性末尾的空格有问题? It was working a while ago. 前一段时间在工作。

This <a title="Lorem ipsum " href="http://example.com">Lorem ipsum</a> works fine for me. <a title="Lorem ipsum " href="http://example.com">Lorem ipsum</a>对我来说很好用。 I wouldnt say it was JS, or anything like that, you may want to check the surroundings tags (div/h1,h2,p etc), make sure they are all correct. 我不会说这是JS或类似的东西,您可能想检查一下周围的标签(div / h1,h2,p等),确保它们都正确。 This is the only thing it could be. 这是唯一的可能。

Try placing <a title="Lorem ipsum " href="http://example.com">Lorem ipsum</a> in a html document on its own and seeing what the inspect comes back as, as it was fine for me. 尝试将<a title="Lorem ipsum " href="http://example.com">Lorem ipsum</a>放置在html文档中,然后查看检查结果如何,对我来说这很好。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM