Files
freeCodeCamp/curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/nest-an-anchor-element-within-a-paragraph.md
Nicholas Carrigan (he/him) 427444c757 chore(learn): audit files for crowdin (#40838)
* chore(learn): audit files for crowdin

Audits the challenge text in the Responsive Web Design superblock to
account for words/phrases that should not be translated because they
refer to code.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* fix: remove quotes from code

Removes instances of quoted code blocks, or code blocked quotes.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* fix: additional uncaught quote-codes

Thanks Oliver :)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: so many quotes

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: missing punctuation

Noted in a Crowdin comment.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* fix: remove more quotes

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
2021-02-01 12:56:07 -07:00

4.0 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bad87fee1348bd9aede08817 Nest an Anchor Element within a Paragraph 0 https://scrimba.com/p/pVMPUv/cb6k8Cb 18244 nest-an-anchor-element-within-a-paragraph

--description--

You can nest links within other text elements.

<p>
  Here's a <a target="_blank" href="http://freecodecamp.org"> link to freecodecamp.org</a> for you to follow.
</p>

Let's break down the example: Normal text is wrapped in the p element:
<p> Here's a ... for you to follow. </p> Next is the anchor element <a> (which requires a closing tag </a>):
<a> ... </a> target is an anchor tag attribute that specifies where to open the link and the value _blank specifies to open the link in a new tab href is an anchor tag attribute that contains the URL address of the link:
<a href="http://freecodecamp.org"> ... </a> The text, "link to freecodecamp.org", within the a element called anchor text, will display a link to click:
<a href=" ... ">link to freecodecamp.org</a> The final output of the example will look like this:

Here's a link to freecodecamp.org for you to follow.

--instructions--

Nest the existing a element within a new p element. The new paragraph should have text that says View more cat photos, where cat photos is a link, and the rest is plain text.

--hints--

You should have an a element that links to "https://freecatphotoapp.com".

assert(
  $('a[href="https://freecatphotoapp.com"]').length > 0 ||
    $('a[href="http://www.freecatphotoapp.com"]').length > 0
);

Your a element should have the anchor text of cat photos

assert(
  $('a')
    .text()
    .match(/cat\sphotos/gi)
);

You should create a new p element around your a element. There should be at least 3 total p tags in your HTML code.

assert($('p') && $('p').length > 2);

Your a element should be nested within your new p element.

assert(
  $('a[href="https://freecatphotoapp.com"]').parent().is('p') ||
    $('a[href="http://www.freecatphotoapp.com"]').parent().is('p')
);

Your p element should have the text View more (with a space after it).

assert(
  $('a[href="https://freecatphotoapp.com"]')
    .parent()
    .text()
    .match(/View\smore\s/gi) ||
    $('a[href="http://www.freecatphotoapp.com"]')
      .parent()
      .text()
      .match(/View\smore\s/gi)
);

Your a element should not have the text View more.

assert(
  !$('a')
    .text()
    .match(/View\smore/gi)
);

Each of your p elements should have a closing tag.

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

Each of your a elements should have a closing tag.

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>

  <a href="https://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>

--solutions--

<h2>CatPhotoApp</h2>
<main>
  <p>View more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a></p>

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