--- id: bad87fee1348bd9aede08817 title: Nidificare un elemento di ancoraggio all'interno di un paragrafo challengeType: 0 forumTopicId: 18244 dashedName: nest-an-anchor-element-within-a-paragraph --- # --description-- Puoi annidare i link all'interno di altri elementi di testo. ```html

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

``` Andiamo a scomporre l'esempio. Il testo normale viene inserito nell'elemento `p`: ```html

Here's a ... for you to follow.

``` Poi viene l'elemento *anchor*`` (che richiede un tag di chiusura ``): ```html ... ``` `target` è un attributo tag di ancoraggio che specifica dove aprire il collegamento. Il valore `_blank` specifica di aprire il collegamento in una nuova scheda. L' `href` è un attributo tag di ancoraggio che contiene l'indirizzo URL del collegamento: ```html ... ``` Il testo, `link to www.freecodecamp.org` all'interno dell'elemento `a` si chiama testo di ancoraggio, e mostrerà il link sul quale cliccare: ```html link to freecodecamp.org ``` L'output finale dell'esempio sarà simile a questo: Here's a link to www.freecodecamp.org for you to follow. # --instructions-- Annida l'elemento `a` esistente all'interno di un nuovo elemento `p`. Non creare un nuovo elemento di ancoraggio. Il nuovo paragrafo dovrebbe contenere testo che dice `View more cat photos`, dove `cat photos` è un collegamento, e il resto è testo semplice. # --hints-- Dovresti avere un solo elemento `a`. ```js assert( $('a').length === 1 ); ``` L'elemento `a` dovrebbe essere collegato a "`https://www.freecatphotoapp.com`". ```js assert( $('a[href="https://www.freecatphotoapp.com"]').length === 1 ); ``` Il tuo elemento `a` dovrebbe avere il testo di ancoraggio: `cat photos` ```js assert( $('a') .text() .match(/cat\sphotos/gi) ); ``` Dovresti creare un elemento `p`. Ci dovrebbe essere almeno 3 tag `p` nel tuo codice HTML ```js assert($('p') && $('p').length > 2); ``` Il tuo elemento `a` dovrebbe essere annidato nel nuovo elemento `p`. ```js assert( $('a[href="https://www.freecatphotoapp.com"]').parent().is('p') ); ``` Il tuo elemento `p` dovrebbe avere il testo `View more` (con uno spazio dopo di esso). ```js assert( $('a[href="https://www.freecatphotoapp.com"]') .parent() .text() .match(/View\smore\s/gi) ); ``` Il tuo elemento `a` non dovrebbe contenere il testo `View more`. ```js assert( !$('a') .text() .match(/View\smore/gi) ); ``` Ognuno dei tuoi elementi `p` dovrebbe avere un tag di chiusura. ```js assert( code.match(/<\/p>/g) && code.match(/

/g).length === code.match(/

/g) && code.match(//g).length === code.match(/CatPhotoApp

cat photos A cute orange cat lying on its back.

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.

``` # --solutions-- ```html

CatPhotoApp

View more cat photos

A cute orange cat lying on its back.

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.

```