图像上可以有多个 alt 属性吗?
Can there be more than one alt attribute on an image?
这是一个简单的问题,但有什么方法可以让我在 img 上拥有比 alt 更多的东西。
如果有它可能看起来像这样:
<img src="happy.jpeg" alt="happy face" alt="Smiley Face">
或
<img src="happy.jpeg" alt="'happy face', 'Smiley Face'">
HTML Specs 中说:
There must never be two or more attributes on the same start tag whose
names are an ASCII case-insensitive match for each other.
它实际上忽略了同名的第二个属性,只使用第一个。
另外,当您使用 double-quoted 属性值语法指定属性时,
<img src="happy.jpeg" alt="'happy face', 'Smiley Face'">
您只传递这个单个字符串,而不是多个关键字:
'happy face', 'Smiley Face'
这是一个简单的问题,但有什么方法可以让我在 img 上拥有比 alt 更多的东西。 如果有它可能看起来像这样:
<img src="happy.jpeg" alt="happy face" alt="Smiley Face">
或
<img src="happy.jpeg" alt="'happy face', 'Smiley Face'">
HTML Specs 中说:
There must never be two or more attributes on the same start tag whose names are an ASCII case-insensitive match for each other.
它实际上忽略了同名的第二个属性,只使用第一个。
另外,当您使用 double-quoted 属性值语法指定属性时,
<img src="happy.jpeg" alt="'happy face', 'Smiley Face'">
您只传递这个单个字符串,而不是多个关键字:
'happy face', 'Smiley Face'