73 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| id: bad87fee1348bd9aede08817
 | |
| title: Nest an Anchor Element within a Paragraph
 | |
| challengeType: 0
 | |
| videoUrl: ''
 | |
| localeTitle: Anidar un elemento de anclaje dentro de un párrafo
 | |
| ---
 | |
| 
 | |
| ## Description
 | |
| <section id="description"> Puedes anidar enlaces dentro de otros elementos de texto. <blockquote> <p> <br> Aquí hay un enlace <a target="_blank" href="http://freecodecamp.org"> a freecodecamp.org </a> para que lo siga. <br> </p> </blockquote> Desglosemos el ejemplo: el texto normal está envuelto en el elemento <code>p</code> : <br> <code><p> Here's a ... for you to follow. </p></code> siguiente es el elemento de <code>anchor</code> <code><a></code> (que requiere una etiqueta de cierre <code></a></code> ): <br> <code><a> ... </a></code> <code>target</code> es un atributo de etiqueta de anclaje que especifica dónde abrir el enlace y el valor <code>"_blank"</code> especifica que se abra el enlace en una nueva pestaña <code>href</code> es un atributo de etiqueta de anclaje que contiene la dirección URL de el enlace: <br> <code><a href="http://freecodecamp.org"> ... </a></code> El texto, <strong>"link to freecodecamp.org"</strong> , dentro del elemento de <code>anchor text</code> llamado <code>anchor text</code> , mostrará un enlace para hacer clic: <br> <code><a href=" ... ">link to freecodecamp.org</a></code> El resultado final del ejemplo se verá así: <br><p> Aquí hay un <a target="_blank" href="http://freecodecamp.org">enlace a freecodecamp.org</a> para que lo sigas. </p></section>
 | |
| 
 | |
| ## Instructions
 | |
| <section id="instructions"> Ahora nido de su actual <code>a</code> elemento dentro de un nuevo <code>p</code> elemento (justo a continuación de la <code>main</code> elemento). El nuevo párrafo debe tener un texto que diga "Ver más fotos de gatos", donde "fotos de gatos" es un enlace, y el resto del texto es texto sin formato. </section>
 | |
| 
 | |
| ## Tests
 | |
| <section id='tests'>
 | |
| 
 | |
| ```yml
 | |
| tests:
 | |
|   - text: 'Es necesario un <code>a</code> elemento que une a "http://freecatphotoapp.com".'
 | |
|     testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").length > 0 || $("a[href=\"http://www.freecatphotoapp.com\"]").length > 0), "You need an <code>a</code> element that links to "http://freecatphotoapp.com".");'
 | |
|   - text: Su <code>a</code> elemento debe tener el texto de anclaje de fotos "gato"
 | |
|     testString: 'assert($("a").text().match(/cat\sphotos/gi), "Your <code>a</code> element should have the anchor text of "cat photos"");'
 | |
|   - text: Crear un nuevo <code>p</code> elemento alrededor de su <code>a</code> elemento. Debe haber al menos 3 etiquetas <code>p</code> en total en su código HTML.
 | |
|     testString: 'assert($("p") && $("p").length > 2, "Create a new <code>p</code> element around your <code>a</code> element. There should be at least 3 total <code>p</code> tags in your HTML code.");'
 | |
|   - text: Su <code>a</code> elemento debe estar anidada dentro de su nueva <code>p</code> elemento.
 | |
|     testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().is("p") || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().is("p")), "Your <code>a</code> element should be nested within your new <code>p</code> element.");'
 | |
|   - text: Su elemento <code>p</code> debe tener el texto "Ver más" (con un espacio detrás de él).
 | |
|     testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi) || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi)), "Your <code>p</code> element should have the text "View more " (with a space after it).");'
 | |
|   - text: Su <code>a</code> elemento <em>no</em> debería tener el texto "Ver más".
 | |
|     testString: 'assert(!$("a").text().match(/View\smore/gi), "Your <code>a</code> element should <em>not</em> have the text "View more".");'
 | |
|   - text: Asegúrese de que cada uno de sus elementos <code>p</code> tenga una etiqueta de cierre.
 | |
|     testString: 'assert(code.match(/<\/p>/g) && code.match(/<p/g) && code.match(/<\/p>/g).length === code.match(/<p/g).length, "Make sure each of your <code>p</code> elements has a closing tag.");'
 | |
|   - text: Asegúrese de que cada uno de sus <code>a</code> elementos tiene una etiqueta de cierre.
 | |
|     testString: 'assert(code.match(/<\/a>/g) && code.match(/<a/g) && code.match(/<\/a>/g).length === code.match(/<a/g).length, "Make sure each of your <code>a</code> elements has a closing tag.");'
 | |
| 
 | |
| ```
 | |
| 
 | |
| </section>
 | |
| 
 | |
| ## Challenge Seed
 | |
| <section id='challengeSeed'>
 | |
| 
 | |
| <div id='html-seed'>
 | |
| 
 | |
| ```html
 | |
| <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.</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>
 | |
| 
 | |
| ## Solution
 | |
| <section id='solution'>
 | |
| 
 | |
| ```js
 | |
| // solution required
 | |
| ```
 | |
| </section>
 |