freeCodeCamp/curriculum/challenges/portuguese/01-responsive-web-design/basic-html-and-html5/add-images-to-your-website....

76 lines
3.2 KiB
Markdown
Raw Normal View History

---
id: bad87fee1348bd9aedf08812
title: Add Images to Your Website
challengeType: 0
videoUrl: ''
localeTitle: Adicionar imagens ao seu site
---
2018-11-04 13:33:46 +00:00
## Descrição
2019-06-03 17:57:36 +00:00
<section id="description"> Você pode adicionar imagens ao seu site usando o elemento <code>img</code> e apontar para o URL de uma imagem específica usando o atributo <code>src</code> Um exemplo disso seria:
<code>&lt;img src=&quot;https://www.your-image-source.com/your-image.jpg&quot;&gt;</code>
Note que os elementos <code>img</code> são de fechamento automático.
Todos os elementos <code>img</code> <strong>devem</strong> ter um atributo <code>alt</code> . O texto dentro de um atributo <code>alt</code> é usado para leitores de tela para melhorar a acessibilidade e é exibido se a imagem não for carregada.
Nota: Se a imagem é puramente decorativa, usar um atributo <code>alt</code> vazio é uma prática recomendada. Idealmente, o atributo <code>alt</code> não deve conter caracteres especiais, a menos que seja necessário. Vamos adicionar um atributo <code>alt</code> ao nosso exemplo de <code>img</code> acima: <code>&lt;img src=&quot;https://www.your-image-source.com/your-image.jpg&quot; alt=&quot;Author standing on a beach with two thumbs up.&quot;&gt;</code> </section>
2018-11-04 13:33:46 +00:00
## Instruções
2019-06-03 17:57:36 +00:00
<section id="instructions"> Vamos tentar adicionar uma imagem ao nosso site:
Insira uma tag <code>img</code> antes do elemento <code>h2</code> . Agora defina o atributo <code>src</code> para que aponte para este URL: <code>https://bit.ly/fcc-relaxing-cat</code> Por fim, não se esqueça de dar à sua imagem um texto <code>alt</code> . </section>
2019-06-03 17:57:36 +00:00
## Testes
<section id='tests'>
```yml
tests:
- text: Sua página deve ter um elemento de imagem.
testString: 'assert($("img").length > 0, "Your page should have an image element.");'
- text: Sua imagem deve ter um atributo <code>src</code> que aponte para a imagem do gatinho.
testString: 'assert(new RegExp("\/\/bit.ly\/fcc-relaxing-cat|\/\/s3.amazonaws.com\/freecodecamp\/relaxing-cat.jpg", "gi").test($("img").attr("src")), "Your image should have a <code>src</code> attribute that points to the kitten image.");'
- text: Seu elemento de imagem <strong>deve</strong> ter um atributo <code>alt</code> .
testString: 'assert(code.match(/alt\s*?=\s*?(\"|\").*(\"|\")/), "Your image element <strong>must</strong> have an <code>alt</code> attribute.");'
```
</section>
2019-06-03 17:57:36 +00:00
## Desafio
<section id='challengeSeed'>
<div id='html-seed'>
```html
2018-11-04 13:33:46 +00:00
<img src="https://bit.ly/fcc-relaxing-cat" alt="Gatinho">
<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>
```
</div>
</section>
2018-11-04 13:33:46 +00:00
## Solução
<section id='solution'>
2018-11-04 13:33:46 +00:00
```html
<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>
```
</section>