简体   繁体   中英

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). W3C validator throws an error saying that "Attribute href not allowed on element a at this point.". 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. 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. 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.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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