Escaping characters/accessibility

Hi. I’ve been searching for how to escape quotes and apostrophes in alt text for an image, and it seems you simply add an additional " for quote escape and ’ for apostrophe escape, however dev tools seems to indicate a problem. Here is my image tag and the alt text where the issue is occurring:

<img class="images" src="https://66.media.tumblr.com/a7496a1ed3574da6cb367ff6dd058a3a/tumblr_obebelc0hs1u2ragso5_500.gif" alt="Chad Ghostal, evil twin of Tad, turning to the camera and reacting to Elvira. Declaring, ""She''s saucy"" to the home viewers. Van Dyke beard in full view.">

Inspecting this in dev tools shows all remaining text and the closing html bracket for the img marked in red after the text “Declaring,”. I have been back and forth looking for a reason why this is happening. I have also run this through the HTML validator and it indicates the browser is looking for a missing attribute and equal sign. The code editor seems to show no issue at all with the alt text after adding the additional quotes and apostrophes, but dev tools and the validator seem to disagree. My eyes are starting to glaze over in this search for an answer and I could use a pointer. Is there something else I should be looking at to correct this?

Perhaps your editor is considering "" as an end of one part of quoted string and opening of another, which is by editor implicitly joined, but such way of dealing with need to use double and single quotes in attribute text sounds strange.

In HTML the co-called HTML character codes can be used as a part of text inside quotes in attribute. It’s &quot; for double quotes and &apos; for single quote / apostrophe. Also I believe using just single quotes inside of double quotes shouldn’t require escaping and the other way around.
This would look in your example as:
&quot;She's saucy&quot; or &quot;She&apos;s saucy&quot;

1 Like

you are not escaping the character like that, you have created a new string, which is part of a new attribute

to escape a duble quote you need to do \", note, I’m note sure it works in html attributes but it is a thing to try.

The other thing to try is to find different thing to write

I don’t think you need to escape the apostrophe in a string surrounded by double quotes

1 Like

Thank you! I did see that format with &quot; at some point and thought I was looking at JS! Then I read a blog that left out the actual code needed and used the quote and apostrophe in it’s place. The editor seemed to accept that and I was too lazy to try what you gave in the example. One step at a time. Thank you again.

1 Like

Thank you. I was thinking about just dipping out on the text altogether but was wanting to make it descriptive from a suggestion around accessibility. The backslash did not actually work in the attribute section like it would elsewhere, but thank you again for the suggestions!