Escape quotes in an iframe srcdoc value

Try to convert from HTML to XHTML - online tool cruto

     html:
<iframe seamless sandbox srcdoc="<p>Yeah, you can see it <a href="/gallery?mode=cover&amp;page=1">in my gallery</a>."></iframe>


 xhtml:
<iframe seamless="" sandbox="" srcdoc="&lt;p&gt;Yeah, you can see it &lt;a href=" gallery?mode="cover&amp;page=1&quot;">in my gallery&lt;/a&gt;."&gt;</iframe>

Yes you are right.

We can use combination of double quotes and single quotes to escape from escaping them.

But the spec says :

escape quotes // just quotes not specified whether single or double


The spec you linked to only notes that the quotes are escaped because

otherwise the srcdoc attribute would end prematurely.

There is no issue using single quotes for the value as shown in your last example.


If there were single quotes inside the value (e.g., the word "you're"), then you'd have to escape either one or the other.

Tags:

Html

Iframe