How to escape double quotes in a title attribute

harpax picture harpax · Sep 20, 2010 · Viewed 217.7k times · Source

I am trying to use a string that contains double quotes in the title attribute of an anchor. So far I tried these:

<a href=".." title="Some \"text\"">Some text</a>
<!-- The title looks like `Some \` --!>

and

<a href=".." title="Some &quot;text&quot;">Some text</a>
<!-- The title looks like `Some ` --!>

Please note that using single quotes is not an option.

Answer

Māris Kiseļovs picture Māris Kiseļovs · Sep 20, 2010

This variant -

<a title="Some &quot;text&quot;">Hover me</a>

Is correct and it works as expected - you see normal quotes in rendered page.