freeCodeCamp/curriculum/challenges/portuguese/01-responsive-web-design/basic-html-and-html5/turn-an-image-into-a-link.md

2.4 KiB

id title challengeType videoUrl forumTopicId dashedName
bad87fee1348bd9aedf08820 Transformar uma imagem em um link 0 https://scrimba.com/p/pVMPUv/cRdBnUr 18327 turn-an-image-into-a-link

--description--

Você pode transformar elementos em links colocando-os dentro de um elemento a.

Coloque a imagem dentro de um elemento a. Exemplo:

<a href="#"><img src="https://www.bit.ly/fcc-running-cats" alt="Three kittens running towards the camera."></a>

Lembre-se de usar # como valor da propriedade href no elemento a para transformá-lo em um link inativo.

--instructions--

Coloque o elemento de imagem existente dentro do elemento a (de âncora).

Uma vez feito isso, passe o cursor do mouse sobre a imagem. O ponteiro do cursor vai se transformar no ponteiro para clicar em links. A foto agora é um link.

--hints--

O elemento img deve estar dentro do elemento a.

assert($('a').children('img').length > 0);

O elemento a deve ser um link inativo com o atributo href definido com o valor #.

assert(new RegExp('#').test($('a').children('img').parent().attr('href')));

Todos os elementos a devem ter uma tag de fechamento.

assert(
  code.match(/<\/a>/g) &&
    code.match(/<a/g) &&
    code.match(/<\/a>/g).length === code.match(/<a/g).length
);

--seed--

--seed-contents--

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <img src="https://www.bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">

  <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>

--solutions--

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://www.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>