Search code examples
emailhyperlinkhrefnon-breaking-characters

Non breaking space after an href link is being included in the displayed hyperlink


I am having an issue with emails being sent to users from a saved template. In this template there are non-breaking spaces to preserve formatting that is expected, and there is no issue forming the link or sending the email.

However it seems that after going through the mail server when the tags are displayed on their preferred mail service, some users are seeing the hypertext link malformed.

Example, This is how the raw link looks in the message we send,

Log in to <a href=\"https://website"\>https://website</a>&nbsp;to

And this is how users are reporting they are seeing the link in the message,

https://website to

Instead of,

https://website

I was able to pull the raw message from a test email after sending it to myself and didn't see that there was any issue with the encoding. Has anyone dealt with this before?

I am not sure if it may be better to try and strip out the character and replace it with a regular space? Or if there is another way to handle this?


Solution

  • You could try wrapping the link with a <span> and it might solve the problem... Note that I have replaced the escaped double quote \" with a single quote '

    <!DOCTYPE html>
    <html>
    <body>
    <label>Wrapped the link with a span</label>
    <div>
        Log in to <span><a href='https://website'>https://website</a></span>&nbsp;to
    </div>
    </body>
    </html>