2.3 KiB
2.3 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d774c367417b2b2512a9d | Know When Alt Text Should be Left Blank | 0 | 知道Alt文本应该留空 |
Description
alt
属性是必需的。但是,有时图像与已经描述它们的标题分组,或仅用于装饰。在这些情况下, alt
文本可能看似多余或不必要。在已经使用文本内容解释图像或者没有为页面添加含义的情况下, img
仍然需要alt
属性,但可以将其设置为空字符串。这是一个例子: <img src="visualDecoration.jpeg" alt="">
背景图片通常也属于“装饰”标签。但是,它们通常应用CSS规则,因此不是标记屏幕阅读器进程的一部分。 注意 对于带有标题的图像,您可能仍希望包含
alt
文本,因为它有助于搜索引擎对图像内容进行编目。 Instructions
alt
属性添加到img
标记并将其设置为空字符串。 (请注意,图像src
不会链接到实际文件 - 不要担心显示屏中没有显示剑。) Tests
tests:
- text: 你的<code>img</code>标签应该有一个<code>alt</code>属性。
testString: 'assert(!($("img").attr("alt") == undefined), "Your <code>img</code> tag should have an <code>alt</code> attribute.");'
- text: <code>alt</code>属性应设置为空字符串。
testString: 'assert($("img").attr("alt") == "", "The <code>alt</code> attribute should be set to an empty string.");'
Challenge Seed
<h1>Deep Thoughts with Master Camper Cat</h1>
<article>
<h2>Defeating your Foe: the Red Dot is Ours!</h2>
<p>To Come...</p>
</article>
<img src="samuraiSwords.jpeg">
<article>
<h2>Is Chuck Norris a Cat Person?</h2>
<p>To Come...</p>
</article>
Solution
// solution required