harpax harpax - 3 months ago 18
HTML Question

How to escape double quotes in title attribute

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>
<!-- title looks like `Some \` --!>


and

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


Please note that using single quotes is not an option.

Answer

This variant -

<a href=".." title="Some &quot;text&quot;">Some text</a>

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

Comments