freeCodeCamp/curriculum/challenges/portuguese/01-responsive-web-design/basic-html-and-html5/link-to-internal-sections-o...

5.1 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad88fee1348bd9aedf08816 Link to Internal Sections of a Page with Anchor Elements 0 Vincular a seções internas de uma página com elementos âncora

Description

Os elementos âncora também podem ser usados para criar links internos para pular para diferentes seções dentro de uma página da Web. Para criar um link interno, atribua o atributo href um link a um símbolo de hash # mais o valor do atributo de id para o elemento que você deseja vincular internamente, geralmente mais abaixo na página. Em seguida, você precisa adicionar o mesmo atributo id ao elemento ao qual está vinculando. Um id é um atributo que descreve exclusivamente um elemento. Abaixo está um exemplo de um link de âncora interna e seu elemento de destino:
<a href="#contacts-header"> Contatos </a>
...
<h2 id = "contatos-cabeçalho"> Contatos </ h2>
Quando os usuários clicam no link Contatos, eles são levados para a seção da página da Web com o elemento de cabeçalho Contatos .

Instructions

Altere seu link externo para um link interno alterando o atributo href para "#footer" e o texto de "cat photos" para "Jump to Bottom". Remova o atributo target="_blank" da tag de âncora, pois isso faz com que o documento vinculado seja aberto em uma nova guia da janela. Em seguida, adicione um atributo id com o valor "footer" ao elemento <footer> na parte inferior da página.

Tests

tests:
  - text: Deve haver apenas uma tag de âncora na sua página.
    testString: 'assert($("a").length == 1, "There should be only one anchor tag on your page.");'
  - text: Deve haver apenas uma tag de <code>footer</code> na sua página.
    testString: 'assert($("footer").length == 1, "There should be only one <code>footer</code> tag on your page.");'
  - text: 'A <code>a</code> tag deve ter um <code>href</code> atributo definido como &quot;#footer&quot;.'
    testString: 'assert($("a").eq(0).attr("href") == "#footer", "The <code>a</code> tag should have an <code>href</code> attribute set to "#footer".");'
  - text: A <code>a</code> tag não deve ter um <code>target</code> atributo
    testString: 'assert(typeof $("a").eq(0).attr("target") == typeof undefined || $("a").eq(0).attr("target") == true, "The <code>a</code> tag should not have a <code>target</code> attribute");'
  - text: A <code>a</code> texto deve ser &quot;Ir para fundo&quot;.
    testString: 'assert($("a").eq(0).text().match(/Jump to Bottom/gi), "The <code>a</code> text should be "Jump to Bottom".");'
  - text: A tag de <code>footer</code> deve ter um atributo <code>id</code> definido como &quot;footer&quot;.
    testString: 'assert($("footer").eq(0).attr("id") == "footer", "The <code>footer</code> tag should have an <code>id</code> attribute set to "footer".");'

Challenge Seed

<h2>CatPhotoApp</h2>
<main>

  <a href="http://freecatphotoapp.com" target="_blank">cat photos</a>

  <img src="https://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. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. 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. Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
  <p>Meowwww loved it, hated it, loved it, hated it yet spill litter box, scratch at owner, destroy all furniture, especially couch or lay on arms while you're using the keyboard. Missing until dinner time toy mouse squeak roll over. With tail in the air lounge in doorway. Man running from cops stops to pet cats, goes to jail.</p>
  <p>Intently stare at the same spot poop in the plant pot but kitten is playing with dead mouse. Get video posted to internet for chasing red dot leave fur on owners clothes meow to be let out and mesmerizing birds leave fur on owners clothes or favor packaging over toy so purr for no reason. Meow to be let out play time intently sniff hand run outside as soon as door open yet destroy couch.</p>

</main>

<footer>Copyright Cat Photo App</footer>

Solution

// solution required