What is prefered to use in alt text "&" or "&" for screenreader users?
Services &a开发者_如何学Pythonmp;amp;
Products
or
Services & Products
Update:
How popular screen readers and text only browsers will handle &
?
Screen readers will read "&" as "and", and text-only browsers will display it as "&".
The reason you write &
is because "&" is a special character in XHTML and must be escaped. Any browser/screenreader that understands XHTML knows that &
is the escaped ampersand ('&') and will display it as such, or read it aloud as "and".
If you're writing an XHTML document, it's not a case of how to make your alt-text more screenreader friendly - you must replace your bare ampersands with &
or risk your document not validating and potentially displaying incorrectly.
In HTML — it doesn't matter (since the ampersand is followed by a space).
In XHTML — &
is a well-formedness error and is completely unacceptable.
You must escape the plain &
with a character reference like &
in order to have a valid XHTML document:
The ampersand character (
&
) […] may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&
" […]
Always escape the ampersand character with the proper character encoding. In HTML it is & or &. In URI it is %26 and not either of the previous two. Not escaping syntax characters will cause XML to fail. If your HTML is ever to be integrated or interpreted by an XML engine your code will break.
精彩评论