Alt text containing double quotes
+0
−0
An image with alt text text with "quote" inside:

An image with alt text unmatched " inside:

The same images with broken links to show the alt text
An image with alt text text with "quote" inside:

An image with alt text unmatched " inside:

1 answer
+0
−0
It turns out the alt text is enclosed in single quotes if the alt text contains double quotes. What happens if the alt text contains both single and double quotes?

The same image with a broken link to show the alt text

How this still works
When the alt text contains both single and double quotes, double quotes are used to contain the alt text, and the contained double quote is represented as ", which the browser renders as " as required:
<img alt="both ' and " inside" src="https://a.dev.codidact.org/assets/logo.png">



0 comment threads