freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-accessibility/add-a-text-alternative-to-images-for-visually-impaired-accessibility.md
Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.8 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
587d774c367417b2b2512a9c 为视觉障碍用户添加替代图像的文本 0 https://scrimba.com/c/cPp7VfD 16628 add-a-text-alternative-to-images-for-visually-impaired-accessibility

--description--

在其他挑战里你应该已经见到过 img 标签的 alt 属性了。alt 属性中的文本作为备用文字来描述图片的内容,这可以帮助用户在图片加载失败或者图片不可见的情况下理解图片内容,也有助于搜索引擎理解图片内容,并将其加入到搜索结果中。例如:

<img src="importantLogo.jpeg" alt="Company logo">

视觉障碍用户无法通过视觉获取信息,而是通过屏幕阅读器将网页内容转换为音频以获取信息。屏幕阅读器可以识别 alt 属性,朗读其中的内容,来告知用户图片包含的关键信息。

alt 文本可以为屏幕阅读器提供图片的描述信息,所以你应始终为图片添加 alt 属性。另外,根据最新的 HTML5 标准,为图片添加 alt 属性是必需的。

--instructions--

碰巧Camper Cat 是忍者中写代码最厉害的,他正在建立一个可以分享忍者知识的网站。在这个网站中,他添加了一张展示技能的资料图片,并希望这张图片可以让访问网站的所有用户看到。请给 img 标签添加一个 alt 属性,说明 Camper Cat 在学习空手道(图片的 src 属性指向的是一个不存在的文件,因此你可以看到 alt 属性中的文本出现在页面上)。

--hints--

img 标签应该包含一个非空的 alt 属性。

assert($('img').attr('alt'));

--seed--

--seed-contents--

<img src="doingKarateWow.jpeg">

--solutions--

<img src="doingKarateWow.jpeg" alt="Someone doing karate">