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

5.2 KiB

id title challengeType videoUrl localeTitle
bad88fee1348bd9aedf08816 Link to Internal Sections of a Page with Anchor Elements 0 Enlace a las secciones internas de una página con elementos de anclaje

Description

Los elementos de anclaje también se pueden usar para crear enlaces internos para saltar a diferentes secciones dentro de una página web. Para crear un enlace interno, asigna el atributo href un enlace a un símbolo de hash # más el valor del atributo id para el elemento al que desea enlazar internamente, generalmente más abajo en la página. A continuación, deberá agregar el mismo atributo de id al elemento al que se está vinculando. Un id es un atributo que describe de forma única un elemento. A continuación se muestra un ejemplo de un enlace de anclaje interno y su elemento de destino:
<a href="#contacts-header"> Contactos </a>
...
<h2 id = "contacts-header"> Contacts </h2>
Cuando los usuarios hacen clic en el enlace de Contactos, serán llevados a la sección de la página web con el elemento del encabezado de Contactos .

Instructions

Cambie su enlace externo a un enlace interno cambiando el atributo href a "# footer" y el texto de "fotos del gato" a "Saltar a la parte inferior". Elimine el atributo target="_blank" de la etiqueta de anclaje ya que esto hace que el documento vinculado se abra en una nueva pestaña de ventana. Luego, agregue un atributo id con un valor de "pie de página" al elemento <footer> en la parte inferior de la página.

Tests

tests:
  - text: Solo debe haber una etiqueta de anclaje en su página.
    testString: 'assert($("a").length == 1, "There should be only one anchor tag on your page.");'
  - text: Solo debe haber una etiqueta de <code>footer</code> en tu página.
    testString: 'assert($("footer").length == 1, "There should be only one <code>footer</code> tag on your page.");'
  - text: 'La <code>a</code> etiqueta debe tener un <code>href</code> atributo establecido en &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: La <code>a</code> etiqueta no debe tener un <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: El <code>a</code> texto debe ser &quot;Saltar a Pie de página&quot;.
    testString: 'assert($("a").eq(0).text().match(/Jump to Bottom/gi), "The <code>a</code> text should be "Jump to Bottom".");'
  - text: La etiqueta de <code>footer</code> debe tener un atributo de <code>id</code> establecido en &quot;pie de página&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