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

6.0 KiB

id title challengeType videoUrl forumTopicId dashedName
bad88fee1348bd9aedf08816 Enlaza hacia secciones internas de una página con los elementos anchor 0 https://scrimba.com/p/pVMPUv/cyrDRUL 301098 link-to-internal-sections-of-a-page-with-anchor-elements

--description--

Los elementos a (anchor) también pueden utilizarse para crear enlaces internos para saltar a diferentes secciones dentro de una página web.

Para crear un enlace interno, asignas el atributo href de un enlace con un símbolo hash # más el valor del atributo id para el elemento al que deseas enlazar internamente, normalmente más abajo de la página. Luego necesitas agregar el mismo atributo id al elemento que estás enlazando. Un id es un atributo que describe un elemento de forma única.

A continuación hay un ejemplo de un enlace interno y su elemento destino:

<a href="#contacts-header">Contacts</a>
...
<h2 id="contacts-header">Contacts</h2>

Cuando los usuarios hagan clic en el enlace Contacts, serán llevados a la sección de la página con el elemento título Contacts.

--instructions--

Cambia tu enlace externo a un enlace interno cambiando el atributo href a #footer y el texto de cat photos a Jump to Bottom.

Elimina el atributo target="_blank" de la etiqueta anchor ya que esto provoca que el documento enlazado se abra en una nueva pestaña.

Luego agrega un atributo id con un valor de footer al elemento <footer> en la parte inferior de la página.

--hints--

Solo debe haber una etiqueta anchor en tu página.

assert($('a').length == 1);

Solo debe haber una etiqueta footer en tu página.

assert($('footer').length == 1);

La etiqueta a debe tener un atributo href establecido como "#footer".

assert($('a').eq(0).attr('href') == '#footer');

La etiqueta a no debe tener un atributo target.

assert(
  typeof $('a').eq(0).attr('target') == typeof undefined ||
    $('a').eq(0).attr('target') == true
);

El texto de a debe ser "Jump to Bottom".

assert(
  $('a')
    .eq(0)
    .text()
    .match(/Jump to Bottom/gi)
);

La etiqueta footer debe tener un atributo id establecido como "footer".

assert($('footer').eq(0).attr('id') == 'footer');

--seed--

--seed-contents--

<h2>CatPhotoApp</h2>
<main>

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

  <img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" 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>

--solutions--

<h2>CatPhotoApp</h2>
<main>

  <a href="#footer">Jump to Bottom</a>

  <img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" 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 id="footer">Copyright Cat Photo App</footer>