3.8 KiB
3.8 KiB
id | title | challengeType | videoUrl | forumTopicId | localeTitle |
---|---|---|---|---|---|
bad87fee1348bd9aedf08812 | Add Images to Your Website | 0 | https://scrimba.com/p/pVMPUv/c8EbJf2 | 16640 | Добавьте изображения на свой сайт |
Description
img
и указывать URL-адрес определенного изображения, используя атрибут src
. Примером этого может быть: <img src="https://www.your-image-source.com/your-image.jpg">
Обратите внимание, что элементы img
самозакрываются. Все элементы img
должны иметь атрибут alt
. Текст внутри атрибута alt
используется для чтения с экрана для улучшения доступности и отображается в виде текста, если изображение не загружается. Примечание. Если изображение является чисто декоративным, использование чистого атрибута alt
является наилучшей практикой. В идеале атрибут alt
не должен содержать специальных символов, если это не требуется. Давайте добавим атрибут alt
к нашему примеру img
выше: <img src="https://www.your-image-source.com/your-image.jpg" alt="Author standing on a beach with two thumbs up.">
Instructions
img
перед элементом h2
. Теперь установите атрибут src
так, чтобы он указывал на этот url: https://bit.ly/fcc-relaxing-cat
Наконец, не забудьте дать вашему изображению текст alt
.
Tests
tests:
- text: Your page should have an image element.
testString: assert($("img").length);
- text: Your image should have a <code>src</code> attribute that points to the kitten image.
testString: assert(/^https:\/\/bit\.ly\/fcc-relaxing-cat$/i.test($("img").attr("src")));
- text: Your image element's <code>alt</code> attribute <strong>must</strong> not be empty.
testString: assert($("img").attr("alt") && $("img").attr("alt").length && /<img\S*alt=(['"])(?!\1|>)\S+\1\S*\/?>/.test(code.replace(/\s/g,'')));
Challenge Seed
<h2>CatPhotoApp</h2>
<main>
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>
Solution
<h2>CatPhotoApp</h2>
<main>
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>